<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <meta name="generator" content="VuePress 2.0.0-beta.60">
    <script>
      (function() {
        const userMode = localStorage.getItem('vuepress-reco-color-scheme') || 'auto';
        const systemDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;

        if (userMode === 'dark' || (userMode === 'auto' && systemDarkMode)) {
          document.documentElement.classList.toggle('dark', true);
        }
      })();
    </script>
    <title>Linux 基础 | 阿派 | Apai Blog</title><meta name="description" content="Just playing around">
    <link rel="modulepreload" href="/assets/app-8a43a0f0.js"><link rel="modulepreload" href="/assets/framework-e1bed10d.js"><link rel="modulepreload" href="/assets/Linux.html-a1058183.js"><link rel="modulepreload" href="/assets/Linux.html-43351365.js"><link rel="prefetch" href="/assets/index.html-ef2f4f01.js" as="script"><link rel="prefetch" href="/assets/index.html-1013d654.js" as="script"><link rel="prefetch" href="/assets/index.html-a146dedc.js" as="script"><link rel="prefetch" href="/assets/index.html-f4b2eaea.js" as="script"><link rel="prefetch" href="/assets/index.html-e3ed352e.js" as="script"><link rel="prefetch" href="/assets/index.html-42ce2ab9.js" as="script"><link rel="prefetch" href="/assets/index.html-ec24ec9e.js" as="script"><link rel="prefetch" href="/assets/index.html-d3d8d7ce.js" as="script"><link rel="prefetch" href="/assets/index.html-9faf073b.js" as="script"><link rel="prefetch" href="/assets/index.html-9364b7dd.js" as="script"><link rel="prefetch" href="/assets/index.html-fc0fb462.js" as="script"><link rel="prefetch" href="/assets/index.html-603c6c19.js" as="script"><link rel="prefetch" href="/assets/index.html-0349deb8.js" as="script"><link rel="prefetch" href="/assets/index.html-09405a87.js" as="script"><link rel="prefetch" href="/assets/index.html-91577c59.js" as="script"><link rel="prefetch" href="/assets/index.html-552ae255.js" as="script"><link rel="prefetch" href="/assets/index.html-424369c4.js" as="script"><link rel="prefetch" href="/assets/index.html-1dfc0069.js" as="script"><link rel="prefetch" href="/assets/index.html-ec62f595.js" as="script"><link rel="prefetch" href="/assets/index.html-4621ef22.js" as="script"><link rel="prefetch" href="/assets/index.html-e189ec13.js" as="script"><link rel="prefetch" href="/assets/index.html-b424a45b.js" as="script"><link rel="prefetch" href="/assets/index.html-623952a8.js" as="script"><link rel="prefetch" href="/assets/index.html-cedcb7c8.js" as="script"><link rel="prefetch" href="/assets/index.html-07f61d2f.js" as="script"><link rel="prefetch" href="/assets/index.html-9ef01f1e.js" as="script"><link rel="prefetch" href="/assets/index.html-dfa6d19f.js" as="script"><link rel="prefetch" href="/assets/index.html-23dd0955.js" as="script"><link rel="prefetch" href="/assets/index.html-1e7a4ff3.js" as="script"><link rel="prefetch" href="/assets/index.html-e12f154a.js" as="script"><link rel="prefetch" href="/assets/index.html-30de2d02.js" as="script"><link rel="prefetch" href="/assets/index.html-6a244983.js" as="script"><link rel="prefetch" href="/assets/index.html-8900b10e.js" as="script"><link rel="prefetch" href="/assets/index.html-b3210461.js" as="script"><link rel="prefetch" href="/assets/biaoqian-fenlei-moban.html-2db9524d.js" as="script"><link rel="prefetch" href="/assets/MuBan-Apai.html-5af383c8.js" as="script"><link rel="prefetch" href="/assets/guide.html-5aaed80e.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-82ee5401.js" as="script"><link rel="prefetch" href="/assets/kaishi.html-9d8493a0.js" as="script"><link rel="prefetch" href="/assets/Hobby-SheYing.html-3ac28a1b.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-96d10c31.js" as="script"><link rel="prefetch" href="/assets/Work-MaYun.html-5e497e8c.js" as="script"><link rel="prefetch" href="/assets/Java-basics.html-4a44925e.js" as="script"><link rel="prefetch" href="/assets/JavaAPI.html-ae8a1843.js" as="script"><link rel="prefetch" href="/assets/JavaBiKeng04.html-c9e75b16.js" as="script"><link rel="prefetch" href="/assets/JavaGongNeng03.html-6ca97faf.js" as="script"><link rel="prefetch" href="/assets/JavaJinJie02.html-eaabb81d.js" as="script"><link rel="prefetch" href="/assets/JavaMyUtil.html-e2cff404.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlus.html-b608a85b.js" as="script"><link rel="prefetch" href="/assets/MySql.html-4bcdc408.js" as="script"><link rel="prefetch" href="/assets/MySqlFunction.html-23affe6f.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ.html-2cc19b22.js" as="script"><link rel="prefetch" href="/assets/Redis.html-f7a014e9.js" as="script"><link rel="prefetch" href="/assets/ShiWuAffair.html-33f5c0c4.js" as="script"><link rel="prefetch" href="/assets/Spring.html-628746d6.js" as="script"><link rel="prefetch" href="/assets/SpringConfig.html-49f3c621.js" as="script"><link rel="prefetch" href="/assets/SpringPeiZhi.html-ac6df88a.js" as="script"><link rel="prefetch" href="/assets/SpringSecurity.html-057633f1.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-57d6fc97.js" as="script"><link rel="prefetch" href="/assets/DockerCompose.html-98ad6b52.js" as="script"><link rel="prefetch" href="/assets/Nginx.html-f1276de6.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ_COPY.html-5cdb6370.js" as="script"><link rel="prefetch" href="/assets/Redis_COPY.html-486e1d26.js" as="script"><link rel="prefetch" href="/assets/Redis_CRUD.html-47e0af0f.js" as="script"><link rel="prefetch" href="/assets/BatJiaoBen.html-d2d2666a.js" as="script"><link rel="prefetch" href="/assets/DmShengChen.html-bb069d8e.js" as="script"><link rel="prefetch" href="/assets/EasyExcel.html-b1eb613d.js" as="script"><link rel="prefetch" href="/assets/GitLu.html-eae89aa5.js" as="script"><link rel="prefetch" href="/assets/JavaKaiFa.html-4fbb86cc.js" as="script"><link rel="prefetch" href="/assets/JSR303.html-b976b418.js" as="script"><link rel="prefetch" href="/assets/MinIO.html-5e3d4702.js" as="script"><link rel="prefetch" href="/assets/ShardingJDBC.html-d0f811b3.js" as="script"><link rel="prefetch" href="/assets/Swagger.html-bb111a21.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-994cf672.js" as="script"><link rel="prefetch" href="/assets/Angular.html-3115afab.js" as="script"><link rel="prefetch" href="/assets/ElementUI.html-35bc6477.js" as="script"><link rel="prefetch" href="/assets/Html-Js.html-015f1806.js" as="script"><link rel="prefetch" href="/assets/Vue-basics.html-a64846f4.js" as="script"><link rel="prefetch" href="/assets/Vue3_group.html-f53be77f.js" as="script"><link rel="prefetch" href="/assets/Vue3_option.html-19f76b9e.js" as="script"><link rel="prefetch" href="/assets/ApifoxAPIceshi.html-19cd8153.js" as="script"><link rel="prefetch" href="/assets/PDManeryuanshujianmo.html-f6fa9d9e.js" as="script"><link rel="prefetch" href="/assets/OCRwenzishibie.html-11fc474d.js" as="script"><link rel="prefetch" href="/assets/EasyExcelbiaogeku.html-30777927.js" as="script"><link rel="prefetch" href="/assets/Javadaimashengchengqi.html-cf566ce0.js" as="script"><link rel="prefetch" href="/assets/JDKshuangbanben.html-1f259d3b.js" as="script"><link rel="prefetch" href="/assets/JSR303canshuxiaoyan.html-78322130.js" as="script"><link rel="prefetch" href="/assets/Mail  youjian.html-7e3a0f69.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlusxiangjie.html-0168c152.js" as="script"><link rel="prefetch" href="/assets/MySQLzhucongfuzhi.html-7a4739e8.js" as="script"><link rel="prefetch" href="/assets/Redis-API.html-f488940c.js" as="script"><link rel="prefetch" href="/assets/SpringBootshiwu.html-c07a3864.js" as="script"><link rel="prefetch" href="/assets/SpringBootduxiefenli.html-f0993780.js" as="script"><link rel="prefetch" href="/assets/Springguolvqihelanjieqi.html-78feb321.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-caecf367.js" as="script"><link rel="prefetch" href="/assets/quanjuyichang-JSR303.html-add01eff.js" as="script"><link rel="prefetch" href="/assets/Docker.html-14746447.js" as="script"><link rel="prefetch" href="/assets/Dockeryuanchengfangwenbushu.html-7dc4f8d3.js" as="script"><link rel="prefetch" href="/assets/Nginxfanxiangdaili.html-42533685.js" as="script"><link rel="prefetch" href="/assets/Apai-SheYingOne.html-143bc574.js" as="script"><link rel="prefetch" href="/assets/Apai-Year.html-b713587f.js" as="script"><link rel="prefetch" href="/assets/My2305.html-b224c5e2.js" as="script"><link rel="prefetch" href="/assets/My2306.html-94838726.js" as="script"><link rel="prefetch" href="/assets/My2307.html-df2118c4.js" as="script"><link rel="prefetch" href="/assets/My2308.html-396c79bc.js" as="script"><link rel="prefetch" href="/assets/My2309.html-1ebdc4bb.js" as="script"><link rel="prefetch" href="/assets/My2310.html-d4ffbd04.js" as="script"><link rel="prefetch" href="/assets/My2311.html-30f23133.js" as="script"><link rel="prefetch" href="/assets/My2312.html-2da62191.js" as="script"><link rel="prefetch" href="/assets/Yi-HuBei.html-90d02bf7.js" as="script"><link rel="prefetch" href="/assets/Yi-ZhuHai.html-e202f6fb.js" as="script"><link rel="prefetch" href="/assets/Apache ECharts tubiao.html-6d4a4703.js" as="script"><link rel="prefetch" href="/assets/Vue3 zuheshi API.html-9fe2887f.js" as="script"><link rel="prefetch" href="/assets/Vue3 xuanxiangshi API.html-d584c181.js" as="script"><link rel="prefetch" href="/assets/Vue3-i18n-guojihuachajian.html-16f6e650.js" as="script"><link rel="prefetch" href="/assets/Batpichulijiaoben.html-307223b0.js" as="script"><link rel="prefetch" href="/assets/Gitgongzuoliu.html-fa6e129f.js" as="script"><link rel="prefetch" href="/assets/Typoratuchuang.html-22c57156.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-df146bdb.js" as="script"><link rel="prefetch" href="/assets/My2401.html-49f6440f.js" as="script"><link rel="prefetch" href="/assets/My2402.html-950d4e85.js" as="script"><link rel="prefetch" href="/assets/shenhai-0509.html-2007281b.js" as="script"><link rel="prefetch" href="/assets/zhuhaixing.html-17db8380.js" as="script"><link rel="prefetch" href="/assets/404.html-f9875e7b.js" as="script"><link rel="prefetch" href="/assets/index.html-40bced6f.js" as="script"><link rel="prefetch" href="/assets/index.html-3c78780e.js" as="script"><link rel="prefetch" href="/assets/index.html-ef51ba1b.js" as="script"><link rel="prefetch" href="/assets/index.html-bdec80a5.js" as="script"><link rel="prefetch" href="/assets/index.html-3b5427f8.js" as="script"><link rel="prefetch" href="/assets/index.html-cbd49540.js" as="script"><link rel="prefetch" href="/assets/index.html-b0b97c81.js" as="script"><link rel="prefetch" href="/assets/index.html-2793d245.js" as="script"><link rel="prefetch" href="/assets/index.html-71d9a5d9.js" as="script"><link rel="prefetch" href="/assets/index.html-4e7d77cd.js" as="script"><link rel="prefetch" href="/assets/index.html-aeace11a.js" as="script"><link rel="prefetch" href="/assets/index.html-c62ed802.js" as="script"><link rel="prefetch" href="/assets/index.html-e640d31f.js" as="script"><link rel="prefetch" href="/assets/index.html-48e1c605.js" as="script"><link rel="prefetch" href="/assets/index.html-385dcb56.js" as="script"><link rel="prefetch" href="/assets/index.html-1bb1a523.js" as="script"><link rel="prefetch" href="/assets/index.html-1ed80e8d.js" as="script"><link rel="prefetch" href="/assets/index.html-2c154a45.js" as="script"><link rel="prefetch" href="/assets/index.html-3e93d436.js" as="script"><link rel="prefetch" href="/assets/index.html-2a93e2c9.js" as="script"><link rel="prefetch" href="/assets/index.html-cff07ba3.js" as="script"><link rel="prefetch" href="/assets/index.html-7ec32a34.js" as="script"><link rel="prefetch" href="/assets/index.html-ddb40108.js" as="script"><link rel="prefetch" href="/assets/index.html-40ab6c4f.js" as="script"><link rel="prefetch" href="/assets/index.html-47e4ee8b.js" as="script"><link rel="prefetch" href="/assets/index.html-c15250e1.js" as="script"><link rel="prefetch" href="/assets/index.html-fb2ea2e4.js" as="script"><link rel="prefetch" href="/assets/index.html-d7e5408a.js" as="script"><link rel="prefetch" href="/assets/index.html-a38055d0.js" as="script"><link rel="prefetch" href="/assets/index.html-be4e50cb.js" as="script"><link rel="prefetch" href="/assets/index.html-660e4bef.js" as="script"><link rel="prefetch" href="/assets/index.html-98aa61ea.js" as="script"><link rel="prefetch" href="/assets/index.html-a6b7472f.js" as="script"><link rel="prefetch" href="/assets/index.html-ab78917a.js" as="script"><link rel="prefetch" href="/assets/biaoqian-fenlei-moban.html-f2c6c309.js" as="script"><link rel="prefetch" href="/assets/MuBan-Apai.html-5714876d.js" as="script"><link rel="prefetch" href="/assets/guide.html-9a89b22b.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-f8203e0a.js" as="script"><link rel="prefetch" href="/assets/kaishi.html-4ff9d0f3.js" as="script"><link rel="prefetch" href="/assets/Hobby-SheYing.html-e1ab7a00.js" as="script"><link rel="prefetch" href="/assets/Lu-aboutMe.html-4b735204.js" as="script"><link rel="prefetch" href="/assets/Work-MaYun.html-a185f330.js" as="script"><link rel="prefetch" href="/assets/Java-basics.html-c0d3a063.js" as="script"><link rel="prefetch" href="/assets/JavaAPI.html-f75cbb54.js" as="script"><link rel="prefetch" href="/assets/JavaBiKeng04.html-d2fc755d.js" as="script"><link rel="prefetch" href="/assets/JavaGongNeng03.html-c51a3060.js" as="script"><link rel="prefetch" href="/assets/JavaJinJie02.html-e5a66660.js" as="script"><link rel="prefetch" href="/assets/JavaMyUtil.html-6e16ee98.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlus.html-1cafeb7e.js" as="script"><link rel="prefetch" href="/assets/MySql.html-5adc8c86.js" as="script"><link rel="prefetch" href="/assets/MySqlFunction.html-2c432c8c.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ.html-d771200f.js" as="script"><link rel="prefetch" href="/assets/Redis.html-aa5c160a.js" as="script"><link rel="prefetch" href="/assets/ShiWuAffair.html-ce7fc825.js" as="script"><link rel="prefetch" href="/assets/Spring.html-3d622ed7.js" as="script"><link rel="prefetch" href="/assets/SpringConfig.html-6fe667f9.js" as="script"><link rel="prefetch" href="/assets/SpringPeiZhi.html-96b777da.js" as="script"><link rel="prefetch" href="/assets/SpringSecurity.html-fe792e2f.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-7fd7be86.js" as="script"><link rel="prefetch" href="/assets/DockerCompose.html-f6ef44c4.js" as="script"><link rel="prefetch" href="/assets/Nginx.html-bf694d87.js" as="script"><link rel="prefetch" href="/assets/RabbitMQ_COPY.html-1e53d902.js" as="script"><link rel="prefetch" href="/assets/Redis_COPY.html-ef853ef3.js" as="script"><link rel="prefetch" href="/assets/Redis_CRUD.html-7a4bb7d5.js" as="script"><link rel="prefetch" href="/assets/BatJiaoBen.html-20ec59d7.js" as="script"><link rel="prefetch" href="/assets/DmShengChen.html-92a2db1f.js" as="script"><link rel="prefetch" href="/assets/EasyExcel.html-ac2c3493.js" as="script"><link rel="prefetch" href="/assets/GitLu.html-27823973.js" as="script"><link rel="prefetch" href="/assets/JavaKaiFa.html-ff11bb84.js" as="script"><link rel="prefetch" href="/assets/JSR303.html-0c745945.js" as="script"><link rel="prefetch" href="/assets/MinIO.html-958125dd.js" as="script"><link rel="prefetch" href="/assets/ShardingJDBC.html-ce0afe07.js" as="script"><link rel="prefetch" href="/assets/Swagger.html-9c9fb3be.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-4e07419a.js" as="script"><link rel="prefetch" href="/assets/Angular.html-3e716bd5.js" as="script"><link rel="prefetch" href="/assets/ElementUI.html-70835a6c.js" as="script"><link rel="prefetch" href="/assets/Html-Js.html-848bb521.js" as="script"><link rel="prefetch" href="/assets/Vue-basics.html-772005d8.js" as="script"><link rel="prefetch" href="/assets/Vue3_group.html-69369e84.js" as="script"><link rel="prefetch" href="/assets/Vue3_option.html-37ac05d4.js" as="script"><link rel="prefetch" href="/assets/ApifoxAPIceshi.html-0bcb1468.js" as="script"><link rel="prefetch" href="/assets/PDManeryuanshujianmo.html-4c377e02.js" as="script"><link rel="prefetch" href="/assets/OCRwenzishibie.html-b4248616.js" as="script"><link rel="prefetch" href="/assets/EasyExcelbiaogeku.html-511b0f0b.js" as="script"><link rel="prefetch" href="/assets/Javadaimashengchengqi.html-33991c95.js" as="script"><link rel="prefetch" href="/assets/JDKshuangbanben.html-8bba14d4.js" as="script"><link rel="prefetch" href="/assets/JSR303canshuxiaoyan.html-7d12c0ef.js" as="script"><link rel="prefetch" href="/assets/Mail  youjian.html-d520132f.js" as="script"><link rel="prefetch" href="/assets/MyBatisPlusxiangjie.html-94d1940a.js" as="script"><link rel="prefetch" href="/assets/MySQLzhucongfuzhi.html-bf156f04.js" as="script"><link rel="prefetch" href="/assets/Redis-API.html-534cd405.js" as="script"><link rel="prefetch" href="/assets/SpringBootshiwu.html-a83407ed.js" as="script"><link rel="prefetch" href="/assets/SpringBootduxiefenli.html-e50eba32.js" as="script"><link rel="prefetch" href="/assets/Springguolvqihelanjieqi.html-b7cdfd68.js" as="script"><link rel="prefetch" href="/assets/WebSocket.html-7c2b5253.js" as="script"><link rel="prefetch" href="/assets/quanjuyichang-JSR303.html-1f70d8b7.js" as="script"><link rel="prefetch" href="/assets/Docker.html-51026828.js" as="script"><link rel="prefetch" href="/assets/Dockeryuanchengfangwenbushu.html-f42be316.js" as="script"><link rel="prefetch" href="/assets/Nginxfanxiangdaili.html-a98dc972.js" as="script"><link rel="prefetch" href="/assets/Apai-SheYingOne.html-b5b7ae7c.js" as="script"><link rel="prefetch" href="/assets/Apai-Year.html-ce260a3f.js" as="script"><link rel="prefetch" href="/assets/My2305.html-8daa1c69.js" as="script"><link rel="prefetch" href="/assets/My2306.html-893e00c1.js" as="script"><link rel="prefetch" href="/assets/My2307.html-e78450ff.js" as="script"><link rel="prefetch" href="/assets/My2308.html-0e38205b.js" as="script"><link rel="prefetch" href="/assets/My2309.html-06a48ebc.js" as="script"><link rel="prefetch" href="/assets/My2310.html-59afa2c3.js" as="script"><link rel="prefetch" href="/assets/My2311.html-b634eab1.js" as="script"><link rel="prefetch" href="/assets/My2312.html-aafaa08a.js" as="script"><link rel="prefetch" href="/assets/Yi-HuBei.html-61c8ef5d.js" as="script"><link rel="prefetch" href="/assets/Yi-ZhuHai.html-26a46f60.js" as="script"><link rel="prefetch" href="/assets/Apache ECharts tubiao.html-e9cc0012.js" as="script"><link rel="prefetch" href="/assets/Vue3 zuheshi API.html-11ae0fbc.js" as="script"><link rel="prefetch" href="/assets/Vue3 xuanxiangshi API.html-ce744458.js" as="script"><link rel="prefetch" href="/assets/Vue3-i18n-guojihuachajian.html-1fa338e8.js" as="script"><link rel="prefetch" href="/assets/Batpichulijiaoben.html-06ab27bc.js" as="script"><link rel="prefetch" href="/assets/Gitgongzuoliu.html-b1e45d5c.js" as="script"><link rel="prefetch" href="/assets/Typoratuchuang.html-cb5c9b25.js" as="script"><link rel="prefetch" href="/assets/Vuepress.html-c36453a2.js" as="script"><link rel="prefetch" href="/assets/My2401.html-9b16cb88.js" as="script"><link rel="prefetch" href="/assets/My2402.html-3ade37a1.js" as="script"><link rel="prefetch" href="/assets/shenhai-0509.html-648d7d95.js" as="script"><link rel="prefetch" href="/assets/zhuhaixing.html-7d486783.js" as="script"><link rel="prefetch" href="/assets/404.html-7c90b0cc.js" as="script"><link rel="prefetch" href="/assets/reco-valine-a0c1af1f.js" as="script">
    <link rel="preload" href="/assets/style-8a0f09c6.css" as="style"><link rel="stylesheet" href="/assets/style-8a0f09c6.css">
  </head>
  <body>
    <div id="app"><!--[--><div class="theme-container"><div class="common-wrapper show-series show-catalog"><div><header class="navbar-container"><!--[--><div class="site-brand nav-item"><img class="logo" src="/logo.png" alt="阿派 | Apai Blog"><a href="/" class="site-name can-hide">阿派 | Apai Blog</a></div><div class="nav-item navbar-links-wrapper" style=""><form class="search-box" role="search"><input type="search" autocomplete="off" spellcheck="false" value><!----></form><nav class="navbar-links"><!--[--><div class="navbar-links__item"><a href="/" class="link router-link-active" aria-label="Home"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Home<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/categories/Java/1/" class="link" aria-label="分类组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->分类组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/tags/Rests/1/" class="link" aria-label="标签组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->标签组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="文档组"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="文档组"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Web-develop/Html-Js" class="link" aria-label="Web-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Web-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Java-develop/JavaMyUtil" class="link" aria-label="Java-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Java-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Linux-develop/Linux" class="link router-link-active" aria-label="Linux-系统"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux-系统<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Rests-docs/Vuepress" class="link" aria-label="Apai-其他"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Apai-其他<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="花圃里"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="花圃里"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2023/My2307" class="link" aria-label="2023-花开万里"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2023-花开万里<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2024/My2401" class="link" aria-label="2024-随心而来"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2024-随心而来<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><a href="/docs/Apai-AboutMe/Lu-aboutMe" class="link" aria-label="关于我"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->关于我<!--]--></span></span><!--[--><!--]--></a></div><!--]--></nav><span class="xicon-container btn-toggle-dark-mode btn--dark-mode"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M15 2h2v3h-2z" fill="currentColor"></path><path d="M27 15h3v2h-3z" fill="currentColor"></path><path d="M15 27h2v3h-2z" fill="currentColor"></path><path d="M2 15h3v2H2z" fill="currentColor"></path><path d="M5.45 6.884l1.414-1.415l2.121 2.122l-1.414 1.414z" fill="currentColor"></path><path d="M23 7.58l2.121-2.12l1.414 1.414l-2.121 2.121z" fill="currentColor"></path><path d="M23.002 24.416l1.415-1.414l2.12 2.122l-1.413 1.414z" fill="currentColor"></path><path d="M5.47 25.13L7.59 23L9 24.42l-2.12 2.12l-1.41-1.41z" fill="currentColor"></path><path d="M16 8a8 8 0 1 0 8 8a8 8 0 0 0-8-8zm0 14a6 6 0 0 1 0-12z" fill="currentColor"></path></svg></span><span class="xicon-container btn-toggle-menus"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><circle cx="16" cy="8" r="2" fill="currentColor"></circle><circle cx="16" cy="16" r="2" fill="currentColor"></circle><circle cx="16" cy="24" r="2" fill="currentColor"></circle></svg></span></div><!--]--></header><div class="mobile-menus-container"><nav class="navbar-links mobile"><!--[--><div class="navbar-links__item"><a href="/" class="link router-link-active" aria-label="Home"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Home<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/categories/Java/1/" class="link" aria-label="分类组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->分类组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><a href="/tags/Rests/1/" class="link" aria-label="标签组"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->标签组<!--]--></span></span><!--[--><!--]--></a></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="文档组"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="文档组"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文档组<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Web-develop/Html-Js" class="link" aria-label="Web-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Web-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Java-develop/JavaMyUtil" class="link" aria-label="Java-开发"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Java-开发<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Linux-develop/Linux" class="link router-link-active" aria-label="Linux-系统"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux-系统<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Rests-docs/Vuepress" class="link" aria-label="Apai-其他"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Apai-其他<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><div class="dropdown-link"><button class="dropdown-link__title" type="button" aria-label="花圃里"><span class="xicon-container left title"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span><span class="arrow down"></span></button><button class="dropdown-link--mobile__title" type="button" aria-label="花圃里"><span class="title"><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->花圃里<!--]--></span></span></span><span class="right arrow"></span></button><ul style="display:none;" class="dropdown-link__container"><!--[--><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2023/My2307" class="link" aria-label="2023-花开万里"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2023-花开万里<!--]--></span></span><!--[--><!--]--></a></li><li class="dropdown-link__item"><a href="/docs/Apai-MyRecord/My-2024/My2401" class="link" aria-label="2024-随心而来"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2024-随心而来<!--]--></span></span><!--[--><!--]--></a></li><!--]--></ul></div></div><div class="navbar-links__item"><a href="/docs/Apai-AboutMe/Lu-aboutMe" class="link" aria-label="关于我"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->关于我<!--]--></span></span><!--[--><!--]--></a></div><!--]--></nav><div class="appearance"><span>Appearance</span><span class="xicon-container btn-toggle-dark-mode"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M15 2h2v3h-2z" fill="currentColor"></path><path d="M27 15h3v2h-3z" fill="currentColor"></path><path d="M15 27h2v3h-2z" fill="currentColor"></path><path d="M2 15h3v2H2z" fill="currentColor"></path><path d="M5.45 6.884l1.414-1.415l2.121 2.122l-1.414 1.414z" fill="currentColor"></path><path d="M23 7.58l2.121-2.12l1.414 1.414l-2.121 2.121z" fill="currentColor"></path><path d="M23.002 24.416l1.415-1.414l2.12 2.122l-1.413 1.414z" fill="currentColor"></path><path d="M5.47 25.13L7.59 23L9 24.42l-2.12 2.12l-1.41-1.41z" fill="currentColor"></path><path d="M16 8a8 8 0 1 0 8 8a8 8 0 0 0-8-8zm0 14a6 6 0 0 1 0-12z" fill="currentColor"></path></svg></span></div></div><div class="series-mask"></div><aside class="series-container"><div class="site-brand"><img class="logo" src="/logo.png" alt="阿派 | Apai Blog"><a href="/" class="site-name can-hide">阿派 | Apai Blog</a></div><!--[--><!--[--><section class="series-group series-item"><h5 class="series-heading active">Linux 基础</h5><ul><li><!--[--><a aria-current="page" href="/docs/Linux-develop/Linux.html" class="router-link-active router-link-exact-active link router-link-active series-item active" aria-label="Linux 基础"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux 基础<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--[--><section class="series-group series-item"><h5 class="series-heading">Linux 应用</h5><ul><li><!--[--><a href="/docs/Linux-develop/Redis_COPY.html" class="link series-item" aria-label="Redis 摘要"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Redis 摘要<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Linux-develop/RabbitMQ_COPY.html" class="link series-item" aria-label="RabbitMQ 摘要"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->RabbitMQ 摘要<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Linux-develop/Redis_CRUD.html" class="link series-item" aria-label="Redis API"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Redis API<!--]--></span></span><!--[--><!--]--></a><!--]--></li><li><!--[--><a href="/docs/Linux-develop/Nginx.html" class="link series-item" aria-label="Nginx 反向代理"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Nginx 反向代理<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--[--><section class="series-group series-item"><h5 class="series-heading">Linux 技术集</h5><ul><li><!--[--><a href="/docs/Linux-develop/DockerCompose.html" class="link series-item" aria-label="DockerCompose 服务编排"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->DockerCompose 服务编排<!--]--></span></span><!--[--><!--]--></a><!--]--></li></ul></section><!--]--><!--]--></aside><!--[--><main class="page-container"><h1 class="page-title">Linux 基础</h1><div class="page-info"><span class="xicon-container left"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:18px;height:18px;font-size:18px;color:inherit;"><path d="M16 4a5 5 0 1 1-5 5a5 5 0 0 1 5-5m0-2a7 7 0 1 0 7 7a7 7 0 0 0-7-7z" fill="currentColor"></path><path d="M26 30h-2v-5a5 5 0 0 0-5-5h-6a5 5 0 0 0-5 5v5H6v-5a7 7 0 0 1 7-7h6a7 7 0 0 1 7 7z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->LuisApai<!--]--></span></span><span class="xicon-container left"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:18px;height:18px;font-size:18px;color:inherit;"><path d="M26 4h-4V2h-2v2h-8V2h-2v2H6c-1.1 0-2 .9-2 2v20c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 22H6V12h20v14zm0-16H6V6h4v2h2V6h8v2h2V6h4v4z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2023/02/15<!--]--></span></span><!----><!----><!----></div><div class="theme-reco-default-content"><div><h2 id="linux" tabindex="-1"><a class="header-anchor" href="#linux" aria-hidden="true">#</a> Linux</h2><h3 id="文件管理" tabindex="-1"><a class="header-anchor" href="#文件管理" aria-hidden="true">#</a> <strong>文件管理</strong></h3><blockquote><p>d rwx rwx rwx. 2 root root 34 6月 21 16:47 aslic</p><ol><li>类型 d: 文件夹 -: 文件 l: 软连接</li><li>权限 所有者 所属组 其他人</li><li>文件大小</li><li>创建时间</li><li>文件名</li></ol></blockquote><p><img src="https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20220622092610669.png" alt="image-20220622092610669"></p><h3 id="配置全路径名" tabindex="-1"><a class="header-anchor" href="#配置全路径名" aria-hidden="true">#</a> 配置全路径名</h3><p><img src="https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20220627105046702.png" alt="image-20220627105046702"></p><ul><li>在 etc 目录下的 profile 文件下修改</li></ul><blockquote><p>配置全路径名:</p><ul><li>export PS1=&#39;[\u@\h $PWD]$&#39;</li></ul><p>export JAVA_HOME=/root/jdk8 export PATH=$JAVA_HOME/bin:$PATH</p></blockquote><h3 id="linux-系统-固定-ip" tabindex="-1"><a class="header-anchor" href="#linux-系统-固定-ip" aria-hidden="true">#</a> Linux 系统 固定 - IP</h3><p>进入 网络配置文件</p><blockquote><p>/etc/sysconfig/network-scripts</p></blockquote><p><img src="https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20220715140917720.png" alt="image-20220715140917720"></p><p>修改为:</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token constant">TYPE</span><span class="token operator">=</span><span class="token string">&quot;Ethernet&quot;</span>
<span class="token constant">PROXY_METHOD</span><span class="token operator">=</span><span class="token string">&quot;none&quot;</span>
<span class="token constant">BROWSER_ONLY</span><span class="token operator">=</span><span class="token string">&quot;no&quot;</span>
<span class="token constant">BOOTPROTO</span><span class="token operator">=</span><span class="token string">&quot;static&quot;</span>
<span class="token constant">DEFROUTE</span><span class="token operator">=</span><span class="token string">&quot;yes&quot;</span>
<span class="token constant">IPV4_FAILURE_FATAL</span><span class="token operator">=</span><span class="token string">&quot;no&quot;</span>
<span class="token constant">IPV6INIT</span><span class="token operator">=</span><span class="token string">&quot;yes&quot;</span>
<span class="token constant">IPV6_AUTOCONF</span><span class="token operator">=</span><span class="token string">&quot;yes&quot;</span>
<span class="token constant">IPV6_DEFROUTE</span><span class="token operator">=</span><span class="token string">&quot;yes&quot;</span>
<span class="token constant">IPV6_FAILURE_FATAL</span><span class="token operator">=</span><span class="token string">&quot;no&quot;</span>
<span class="token constant">IPV6_ADDR_GEN_MODE</span><span class="token operator">=</span><span class="token string">&quot;stable-privacy&quot;</span>
<span class="token constant">NAME</span><span class="token operator">=</span><span class="token string">&quot;ens33&quot;</span>
<span class="token constant">UUID</span><span class="token operator">=</span><span class="token string">&quot;a83c1999-f7ee-4517-848a-071a0a1bb834&quot;</span>
<span class="token constant">DEVICE</span><span class="token operator">=</span><span class="token string">&quot;ens33&quot;</span>
<span class="token constant">ONBOOT</span><span class="token operator">=</span><span class="token string">&quot;yes&quot;</span>
<span class="token constant">BROADCAST</span><span class="token operator">=</span><span class="token number">192.168</span><span class="token number">.1</span><span class="token number">.255</span>
<span class="token constant">IPADDR</span><span class="token operator">=</span><span class="token number">192.168</span><span class="token number">.174</span><span class="token number">.130</span>  <span class="token comment">// 静态的 IP 地址</span>
<span class="token constant">NETMASK</span><span class="token operator">=</span><span class="token number">255.255</span><span class="token number">.255</span><span class="token number">.0</span>
<span class="token constant">GATEWAY</span><span class="token operator">=</span><span class="token number">192.168</span><span class="token number">.1</span><span class="token number">.1</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>刷新配置 重新使用静态ip连接</p><blockquote><p>service network restart</p></blockquote><h2 id="linux-文件与目录管理" tabindex="-1"><a class="header-anchor" href="#linux-文件与目录管理" aria-hidden="true">#</a> Linux 文件与目录管理</h2><ul><li><p><strong>绝对路径：</strong> 路径的写法，由根目录 <strong>/</strong> 写起，</p><blockquote><p>例如： /usr/share/doc 这个目录。</p></blockquote></li><li><p><strong>相对路径：</strong> 路径的写法，不是由 <strong>/</strong> 写起，</p><blockquote><p>例如由 /usr/share/doc 要到 /usr/share/man 底下时，可以写成： <strong>cd ../man</strong> 这就是相对路径的写法。</p></blockquote></li></ul><h3 id="处理目录的常用命令" tabindex="-1"><a class="header-anchor" href="#处理目录的常用命令" aria-hidden="true">#</a> 处理目录的常用命令</h3><h4 id="ls-列出目录" tabindex="-1"><a class="header-anchor" href="#ls-列出目录" aria-hidden="true">#</a> ls (列出目录)</h4><blockquote><p>ls（英文全拼：list files）: 列出目录及文件名</p></blockquote><p>语法：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## ls [-aAdfFhilnrRSt] 目录名称
[root@www ~]## ls [--color={never,auto,always}] 目录名称
[root@www ~]## ls [--full-time] 目录名称
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li>-a ：全部的文件，连同隐藏文件( 开头为 . 的文件) 一起列出来(常用)</li><li>-d ：仅列出目录本身，而不是列出目录内的文件数据(常用)</li><li>-l ：长数据串列出，包含文件的属性与权限等等数据；(常用)</li></ul><p>将家目录下的所有文件列出来(含属性与隐藏档)</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## ls -al ~
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h4 id="cd-切换目录" tabindex="-1"><a class="header-anchor" href="#cd-切换目录" aria-hidden="true">#</a> cd (切换目录)</h4><blockquote><p>cd 是Change Directory的缩写，这是用来变换工作目录的命令。</p></blockquote><p>语法：</p><div class="language-linux line-numbers-mode" data-ext="linux"><pre class="language-linux"><code>// cd [相对路径或绝对路径]
#使用 mkdir 命令创建 runoob 目录
[root@www ~]## mkdir runoob

#使用绝对路径切换到 runoob 目录
[root@www ~]## cd /root/runoob/

#使用相对路径切换到 runoob 目录
[root@www ~]## cd ./runoob/

## 表示回到自己的家目录，亦即是 /root 这个目录
[root@www runoob]## cd ~

## 表示去到目前的上一级目录，亦即是 /root 的上一级目录的意思；
[root@www ~]## cd ..
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="pwd-显示目前所在的目录" tabindex="-1"><a class="header-anchor" href="#pwd-显示目前所在的目录" aria-hidden="true">#</a> pwd (显示目前所在的目录)</h4><blockquote><p>pwd 是 <strong>Print Working Directory</strong> 的缩写，也就是显示目前所在目录的命令。</p></blockquote><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## pwd [-P]
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li><strong>-P</strong> ：显示出确实的路径，而非使用连结 (link) 路径。</li></ul><p>实例：单纯显示出目前的工作目录：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## pwd
/root   &lt;== 显示出目录啦～
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>实例显示出实际的工作目录，而非连结档本身的目录名而已。</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## cd /var/mail   &lt;== 注意，/var/mail是一个连结档
[root@www mail]## pwd
/var/mail         &lt;==列出目前的工作目录
[root@www mail]## pwd -P
/var/spool/mail   &lt;==怎么回事？有没有加 -P 差很多～
[root@www mail]## ls -ld /var/mail
lrwxrwxrwx 1 root root 10 Sep  4 17:54 /var/mail -&gt; spool/mail
## 看到这里应该知道为啥了吧？因为 /var/mail 是连结档，连结到 /var/spool/mail 
## 所以，加上 pwd -P 的选项后，会不以连结档的数据显示，而是显示正确的完整路径啊！
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="mkdir-创建新目录" tabindex="-1"><a class="header-anchor" href="#mkdir-创建新目录" aria-hidden="true">#</a> mkdir (创建新目录)</h4><blockquote><p>mkdir (make directory) 创建新的目录</p></blockquote><p>语法：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>mkdir [-mp] 目录名称
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li>-m ：配置文件的权限喔！直接配置，不需要看默认权限 (umask) 的脸色～</li><li>-p ：帮助你直接将所需要的目录(包含上一级目录)递归创建起来！</li></ul><p>实例：请到/tmp底下尝试创建数个新目录看看：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## cd /tmp
[root@www tmp]## mkdir test    &lt;==创建一名为 test 的新目录
[root@www tmp]## mkdir test1/test2/test3/test4
mkdir: cannot create directory `test1/test2/test3/test4&#39;: 
No such file or directory       &lt;== 没办法直接创建此目录啊！
[root@www tmp]## mkdir -p test1/test2/test3/test4
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>加了这个 -p 的选项，可以自行帮你创建多层目录！</p><p>实例：创建权限为 <strong>rwx--x--x</strong> 的目录。</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www tmp]## mkdir -m 711 test2
[root@www tmp]## ls -l
drwxr-xr-x  3 root  root 4096 Jul 18 12:50 test
drwxr-xr-x  3 root  root 4096 Jul 18 12:53 test1
drwx--x--x  2 root  root 4096 Jul 18 12:54 test2
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上面的权限部分，如果没有加上 -m 来强制配置属性，系统会使用默认属性。</p><p>如果我们使用 -m ，如上例我们给予 -m 711 来给予新的目录 drwx--x--x 的权限。</p><h4 id="touch-创建新文件" tabindex="-1"><a class="header-anchor" href="#touch-创建新文件" aria-hidden="true">#</a> touch (创建新文件)</h4><blockquote><p>touch 创建新的文件</p></blockquote><p>语法：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>// touch 文件名
touch test.txt
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="rmdir-删除空的目录" tabindex="-1"><a class="header-anchor" href="#rmdir-删除空的目录" aria-hidden="true">#</a> rmdir (删除空的目录)</h4><p>语法：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code> rmdir [-p] 目录名称
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li>**-p ：**从该目录起，一次删除多级空目录</li></ul><p>删除 runoob 目录</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www tmp]## rmdir runoob/
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>将 mkdir 实例中创建的目录(/tmp 底下)删除掉！</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www tmp]## ls -l   &lt;==看看有多少目录存在？
drwxr-xr-x  3 root  root 4096 Jul 18 12:50 test
drwxr-xr-x  3 root  root 4096 Jul 18 12:53 test1
drwx--x--x  2 root  root 4096 Jul 18 12:54 test2
[root@www tmp]## rmdir test   &lt;==可直接删除掉，没问题
[root@www tmp]## rmdir test1  &lt;==因为尚有内容，所以无法删除！
rmdir: `test1&#39;: Directory not empty
[root@www tmp]## rmdir -p test1/test2/test3/test4
[root@www tmp]## ls -l        &lt;==您看看，底下的输出中test与test1不见了！
drwx--x--x  2 root  root 4096 Jul 18 12:54 test2
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>利用 -p 这个选项，立刻就可以将 test1/test2/test3/test4 一次删除。</p><p>不过要注意的是，这个 rmdir 仅能删除空的目录，你可以使用 rm 命令来删除非空目录。</p><h4 id="cp-复制文件或目录" tabindex="-1"><a class="header-anchor" href="#cp-复制文件或目录" aria-hidden="true">#</a> cp (复制文件或目录)</h4><blockquote><p>cp 即拷贝文件和目录。</p></blockquote><p>语法:</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## cp [-adfilprsu] 来源档(source) 目标档(destination)
[root@www ~]## cp [options] source1 source2 source3 .... directory
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li>**-a：**相当於 -pdr 的意思，至於 pdr 请参考下列说明；(常用)</li><li>**-d：**若来源档为连结档的属性(link file)，则复制连结档属性而非文件本身；</li><li>**-f：**为强制(force)的意思，若目标文件已经存在且无法开启，则移除后再尝试一次；</li><li>**-i：**若目标档(destination)已经存在时，在覆盖时会先询问动作的进行(常用)</li><li>**-l：**进行硬式连结(hard link)的连结档创建，而非复制文件本身；</li><li>**-p：**连同文件的属性一起复制过去，而非使用默认属性(备份常用)；</li><li>**-r：**递归持续复制，用於目录的复制行为；(常用)</li><li>**-s：**复制成为符号连结档 (symbolic link)，亦即『捷径』文件；</li><li>**-u：**若 destination 比 source 旧才升级 destination ！</li></ul><p>用 root 身份，将 root 目录下的 .bashrc 复制到 /tmp 下，并命名为 bashrc</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## cp ~/.bashrc /tmp/bashrc
[root@www ~]## cp -i ~/.bashrc /tmp/bashrc
cp: overwrite `/tmp/bashrc&#39;? n  &lt;==n不覆盖，y为覆盖
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="rm-移除文件或目录" tabindex="-1"><a class="header-anchor" href="#rm-移除文件或目录" aria-hidden="true">#</a> rm (移除文件或目录)</h4><p>语法：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code> rm [-fir] 文件或目录
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li>-f ：就是 force 的意思，忽略不存在的文件，不会出现警告信息；</li><li>-i ：互动模式，在删除前会询问使用者是否动作</li><li>-r ：递归删除啊！最常用在目录的删除了！这是非常危险的选项！！！</li><li>-rf 组合使用</li></ul><p>将刚刚在 cp 的实例中创建的 bashrc 删除掉！</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www tmp]## rm -i bashrc
rm: remove regular file `bashrc&#39;? y
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>如果加上 -i 的选项就会主动询问喔，避免你删除到错误的档名！</p><h4 id="mv-移动文件与目录-或修改名称" tabindex="-1"><a class="header-anchor" href="#mv-移动文件与目录-或修改名称" aria-hidden="true">#</a> mv (移动文件与目录，或修改名称)</h4><p>语法：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## mv [-fiu] source destination
[root@www ~]## mv [options] source1 source2 source3 .... directory
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li>-f ：force 强制的意思，如果目标文件已经存在，不会询问而直接覆盖；</li><li>-i ：若目标文件 (destination) 已经存在时，就会询问是否覆盖！</li><li>-u ：若目标文件已经存在，且 source 比较新，才会升级 (update)</li></ul><p>复制一文件，创建一目录，将文件移动到目录中</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## cd /tmp
[root@www tmp]## cp ~/.bashrc bashrc
[root@www tmp]## mkdir mvtest
[root@www tmp]## mv bashrc mvtest
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>将某个文件移动到某个目录去，就是这样做！</p><p>将刚刚的目录名称更名为 mvtest2</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www tmp]## mv mvtest mvtest2
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="linux-文件内容查看" tabindex="-1"><a class="header-anchor" href="#linux-文件内容查看" aria-hidden="true">#</a> Linux 文件内容查看</h3><p>Linux系统中使用以下命令来查看文件的内容：</p><ul><li>cat 由第一行开始显示文件内容</li><li>tac 从最后一行开始显示，可以看出 tac 是 cat 的倒着写！</li><li>nl 显示的时候，顺道输出行号！</li><li>more 一页一页的显示文件内容</li><li>less 与 more 类似，但是比 more 更好的是，他可以往前翻页！</li><li>head 只看头几行</li><li>tail 只看尾巴几行</li></ul><p>你可以使用 *man [命令]*来查看各个命令的使用文档，如 ：man cp。</p><h4 id="cat-由第一行开始显示文件内容" tabindex="-1"><a class="header-anchor" href="#cat-由第一行开始显示文件内容" aria-hidden="true">#</a> cat (由第一行开始显示文件内容)</h4><p>语法：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>cat [-AbEnTv]
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li>-A ：相当於 -vET 的整合选项，可列出一些特殊字符而不是空白而已；</li><li>-b ：列出行号，仅针对非空白行做行号显示，空白行不标行号！</li><li>-E ：将结尾的断行字节 $ 显示出来；</li><li>-n ：列印出行号，连同空白行也会有行号，与 -b 的选项不同；</li><li>-T ：将 [tab] 按键以 ^I 显示出来；</li><li>-v ：列出一些看不出来的特殊字符</li></ul><p>检看 /etc/issue 这个文件的内容：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="tac-最后一行开始显示" tabindex="-1"><a class="header-anchor" href="#tac-最后一行开始显示" aria-hidden="true">#</a> tac (最后一行开始显示)</h4><p>tac与cat命令刚好相反，文件内容从最后一行开始显示，可以看出 tac 是 cat 的倒着写！如：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## tac /etc/issue

Kernel \r on an \m
CentOS release 6.4 (Final)
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="nl" tabindex="-1"><a class="header-anchor" href="#nl" aria-hidden="true">#</a> nl</h4><p>显示行号</p><p>语法：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>nl [-bnw] 文件
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li>-b ：指定行号指定的方式，主要有两种： -b a ：表示不论是否为空行，也同样列出行号(类似 cat -n)； -b t ：如果有空行，空的那一行不要列出行号(默认值)；</li><li>-n ：列出行号表示的方法，主要有三种： -n ln ：行号在荧幕的最左方显示； -n rn ：行号在自己栏位的最右方显示，且不加 0 ； -n rz ：行号在自己栏位的最右方显示，且加 0 ；</li><li>-w ：行号栏位的占用的位数。</li></ul><p>实例一：用 nl 列出 /etc/issue 的内容</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## nl /etc/issue
     1  CentOS release 6.4 (Final)
     2  Kernel \r on an \m
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="more-翻页" tabindex="-1"><a class="header-anchor" href="#more-翻页" aria-hidden="true">#</a> more(翻页)</h4><p>一页一页翻动</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## more /etc/man_db.config 
#
## Generated automatically from man.conf.in by the
## configure script.
#
## man.conf from man-1.6d
....(中间省略)....
--More--(28%)  &lt;== 重点在这一行喔！你的光标也会在这里等待你的命令
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>在 more 这个程序的运行过程中，你有几个按键可以按的：</p><ul><li>空白键 (space)：代表向下翻一页；</li><li>Enter ：代表向下翻『一行』；</li><li>/字串 ：代表在这个显示的内容当中，向下搜寻『字串』这个关键字；</li><li>:f ：立刻显示出档名以及目前显示的行数；</li><li>q ：代表立刻离开 more ，不再显示该文件内容。</li><li>b 或 [ctrl]-b ：代表往回翻页，不过这动作只对文件有用，对管线无用。</li></ul><h4 id="less-滚动查看" tabindex="-1"><a class="header-anchor" href="#less-滚动查看" aria-hidden="true">#</a> less (滚动查看)</h4><p>一页一页翻动，以下实例输出/etc/man.config文件的内容：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## less /etc/man.config
#
## Generated automatically from man.conf.in by the
## configure script.
#
## man.conf from man-1.6d
....(中间省略)....
:   &lt;== 这里可以等待你输入命令！
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>less运行时可以输入的命令有：</p><ul><li>空白键 ：向下翻动一页；</li><li>[pagedown]：向下翻动一页；</li><li>[pageup] ：向上翻动一页；</li><li>/字串 ：向下搜寻『字串』的功能；</li><li>?字串 ：向上搜寻『字串』的功能；</li><li>n ：重复前一个搜寻 (与 / 或 ? 有关！)</li><li>N ：反向的重复前一个搜寻 (与 / 或 ? 有关！)</li><li>q ：离开 less 这个程序；</li></ul><h4 id="head" tabindex="-1"><a class="header-anchor" href="#head" aria-hidden="true">#</a> head</h4><p>取出文件前面几行</p><p>语法：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>head [-n number] 文件 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li>-n ：后面接数字，代表显示几行的意思</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## head /etc/man.config
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>默认的情况中，显示前面 10 行！若要显示前 20 行，就得要这样：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## head -n 20 /etc/man.config
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h4 id="tail" tabindex="-1"><a class="header-anchor" href="#tail" aria-hidden="true">#</a> tail</h4><blockquote><p>取出文件后面几行</p></blockquote><p>语法：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>tail [-n number] 文件 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>选项与参数：</p><ul><li>-n ：后面接数字，代表显示几行的意思</li><li>-f ：表示持续侦测后面所接的档名，要等到按下[ctrl]-c才会结束tail的侦测</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>[root@www ~]## tail /etc/man.config
## 默认的情况中，显示最后的十行！若要显示最后的 20 行，就得要这样：
[root@www ~]## tail -n 20 /etc/man.config
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="linux-功能类命令" tabindex="-1"><a class="header-anchor" href="#linux-功能类命令" aria-hidden="true">#</a> Linux 功能类命令</h3><h4 id="ln-链接命令" tabindex="-1"><a class="header-anchor" href="#ln-链接命令" aria-hidden="true">#</a> ln 链接命令</h4><blockquote><p>硬链接 - 相对于复制但是能够继承其所有属性</p><p>拷贝cp -p + 同步更新</p><p>可通过i节点识别</p><p>不能跨分区</p><p>不能针对目录使用</p></blockquote><blockquote><p>软连接</p><p>软链接文件权限都为rwxrwxrwx</p><p>文件大小-只是符号链接</p><p>/tmp/issue.soft -&gt; /etc/issue 箭头指向原文件</p></blockquote><p>语法</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code> ln [参数][源文件或目录][目标文件或目录]
 ln wuwei.txt wuwu.txt
 ln -s  wuwei.txt wuwuss.txt
 硬链接和软连接不是根据文件的扩展名规定的，加了-s就是软连接，否则就是硬连接  
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="chmod-权限管理命令" tabindex="-1"><a class="header-anchor" href="#chmod-权限管理命令" aria-hidden="true">#</a> chmod 权限管理命令</h4><blockquote><p>功能描述：改变文件或目录权限</p></blockquote><p><strong>语法：</strong></p><p><strong>chmod [{ugoa}{+-=}{rwx}] [文件或目录] 如: chmod g+w aslic</strong></p><p><strong>chmod [mode=421 ] [文件或目录] 如: chmod 141 aslic</strong></p><p><strong>chmod -R [mode=421 ] [文件或目录]如: chmod -R 141 aslic</strong></p><table><thead><tr><th style="text-align:center;">代表字符</th><th style="text-align:center;">数字</th><th>权限</th><th>对文件的含义</th><th>对目录的含义</th></tr></thead><tbody><tr><td style="text-align:center;">r</td><td style="text-align:center;">4</td><td>读权限</td><td>可以查看文件 内容</td><td>可以列出目录中 的内容</td></tr><tr><td style="text-align:center;">w</td><td style="text-align:center;">2</td><td>写权限</td><td>可以修改文件 内容</td><td>可以在目录中创 建、删除文件</td></tr><tr><td style="text-align:center;">x</td><td style="text-align:center;">1</td><td>执行权限</td><td>可以执行文件</td><td>可以进入目录</td></tr></tbody></table><h4 id="find-文件搜索命令" tabindex="-1"><a class="header-anchor" href="#find-文件搜索命令" aria-hidden="true">#</a> find 文件搜索命令</h4><blockquote><p>功能描述：文件或者文件夹搜索</p></blockquote><p><strong>语法：find [搜索范围 - 目录路径] [匹配条件]</strong></p><p>选项:</p><ul><li><p>条件类型: -name 名称 -type 类型 ( p -&gt; ,目录 / f -&gt; 文件 ) -size 大小</p><p>-group 所属组查找 -cmin -5 查询5分钟内被修改过属性的文件和目录</p></li><li><p>通配符: ? -&gt; 占位符(一个字符) * -&gt; 多个匹配</p></li><li><p>-iname 不区分大小写</p></li><li><p>大小对比: +n 大于 -n 小于 n 等于</p></li><li><p>与 或: -a 两个条件同时满足 and -o 两个条件满足任意一个即可 or</p></li><li><p>-exec/-ok 命令 {} ; 对搜索结果执行操作</p></li></ul><p>案例:</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 查询 apai目录下的 包含wu的 且类型为目录</span>
find <span class="token operator">/</span>apai <span class="token operator">-</span>name wu<span class="token operator">*</span> <span class="token operator">-</span>a <span class="token operator">-</span>type f
<span class="token comment">// 查询 根目录下的 大小大于204800 的文件</span>
find <span class="token operator">/</span> <span class="token operator">-</span>size <span class="token operator">+</span><span class="token number">204800</span>
<span class="token comment">// 在根目录下查找所有者为zhangsan的文件</span>
find <span class="token operator">/</span>home <span class="token operator">-</span>user zhangsan
<span class="token comment">// 在/etc下查找5分钟内被修改过属性的文件和目录</span>
find <span class="token operator">/</span>etc <span class="token operator">-</span>cmin <span class="token operator">-</span><span class="token number">5</span>
<span class="token comment">// 在/etc下查找inittab文件并显示其详细信息 -exec/-ok 命令 {} \; 对搜索结果执行操作</span>
find <span class="token operator">/</span> <span class="token operator">-</span>name mengni <span class="token operator">-</span>exec rm <span class="token operator">-</span>rf <span class="token punctuation">{</span> <span class="token punctuation">}</span> \
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="grep-文件内容搜索命令" tabindex="-1"><a class="header-anchor" href="#grep-文件内容搜索命令" aria-hidden="true">#</a> grep 文件内容搜索命令</h4><blockquote><p>在文件中搜寻字串匹配的行并输出</p></blockquote><p>语法：grep [指定字串] [文件]</p><ul><li>-i 不区分大小写</li><li>-v 排除指定字串</li></ul><p>案例</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 在 cs.txt 文件的内容里搜索包含 is 字符串且 -i 不区分大小写 </span>
grep <span class="token operator">-</span>i is cs<span class="token punctuation">.</span>txt
<span class="token comment">// 在 cs.txt 文件的内容里搜索不包含 is 字符串且 -i 不区分大小写 </span>
grep <span class="token operator">-</span>iv is cs<span class="token punctuation">.</span>txt
<span class="token comment">// 从install.log文中找mysql</span>
grep mysql <span class="token operator">/</span>root<span class="token operator">/</span>install<span class="token punctuation">.</span>log  
<span class="token comment">// 把文件inittab每行的开头#去掉 如果不加^ 那么有可能去掉的是内容中间的#</span>
grep <span class="token operator">-</span>v <span class="token operator">^</span>## <span class="token operator">/</span>etc<span class="token operator">/</span>inittab
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="tar-压缩解压命令" tabindex="-1"><a class="header-anchor" href="#tar-压缩解压命令" aria-hidden="true">#</a> tar 压缩解压命令</h3><blockquote><p>tar这个命令既可以打包压缩也可以解压</p><p>注意规范: 打包文件后缀 .tar 压缩文件后缀 .tar.gz</p></blockquote><p>选项:</p><ul><li>-c create 打包</li></ul><ul><li>-x 解包 extract</li><li>-v 显示详细信息</li><li>-f 指定解压文件</li><li>-z 解压缩</li></ul><p><strong>1）tar给一个文件或者一个目录打包</strong> tar -cvf 包名 源文件名</p><p><strong>2）tar给一个打了包的文件解包</strong> tar -xvf 包名 注意：默认是解到当前目录，也可以指定到其他的目录 tar -xvf 包名 -C 目录名</p><p><strong>3）tar给一个文件打包并压缩</strong> tar -zcvf 压缩名 源文件名</p><p><strong>4）tar给一个文件解压缩</strong> tar -zxvf 压缩名 -C 目录名</p><h3 id="网络命令" tabindex="-1"><a class="header-anchor" href="#网络命令" aria-hidden="true">#</a> 网络命令</h3><h4 id="ping-测试网络连通性" tabindex="-1"><a class="header-anchor" href="#ping-测试网络连通性" aria-hidden="true">#</a> ping 测试网络连通性</h4><blockquote><p>测试网络连通性</p></blockquote><p><strong>语法：ping 选项 IP地址</strong></p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>范例： ## ping 192.168.1.156

ping -c 3 192.168.1.156服务器回应3次即可，默认一直回应
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="netstat-网络相关信息" tabindex="-1"><a class="header-anchor" href="#netstat-网络相关信息" aria-hidden="true">#</a> netstat 网络相关信息</h4><blockquote><p>显示网络相关信息</p><p>yum install net-tools</p></blockquote><p>语法：netstat [选项]</p><p>选项： netstat -tlnp</p><ul><li>-t TCP协议 三次握手 网络传输协议 打电话类似</li><li>-u UDP协议 数据包协议 丢包率高，不握手</li><li>-l lisenter 监听</li><li>-r route</li><li>-n number 显示ip和端口号</li></ul><blockquote><p>当前是tcp协议</p><p>第一个0表示网络通畅，接受的数据包队列 没有挤压</p><p>第二个0表示发送的数据包队列，网络通畅</p><p>0.0.0.0 本地的ip地址 111 表示端口</p><p>Stat 表示TCP的监听 UDP没有监听的 注意</p><p>这条信息，表示当前有一台主机192.168.58.1正在连接到 linux192.168.58.128上 端口是22, ESTABLISHED连接</p><p>注意：自己电脑的端口是系统随机分配，不一定也要是22</p><p>## netstat -rn</p><p>显示route路由信息 n：numberic</p></blockquote><h4 id="ifconfig-查看和设置网卡信息" tabindex="-1"><a class="header-anchor" href="#ifconfig-查看和设置网卡信息" aria-hidden="true">#</a> ifconfig 查看和设置网卡信息</h4><blockquote><p>查看和设置网卡信息</p></blockquote><p>语法：ifconfig 网卡名称 IP地址</p><ul><li><p>范例：## ifconfig eth0 192.168.8.250</p></li><li><p>范例：## ifconfig -a #查看所有网卡</p></li></ul><h4 id="last-登入系统的用户信息" tabindex="-1"><a class="header-anchor" href="#last-登入系统的用户信息" aria-hidden="true">#</a> last 登入系统的用户信息</h4><blockquote><p>列出目前与过去登入系统的用户信息</p></blockquote><p>语法：last</p><h4 id="traceroute-数据包到主机的路径" tabindex="-1"><a class="header-anchor" href="#traceroute-数据包到主机的路径" aria-hidden="true">#</a> traceroute 数据包到主机的路径</h4><blockquote><p>显示数据包到主机间的路径</p></blockquote><p>语法：traceroute</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>范例：## traceroute www.lampbrother.net
   	 ## traceroute www.sina.com.cn
访问新浪官网所经过的路由信息ip以及所花费的时间，如果时间长，
表示在某一块路由服务有问题，或者断掉，通过这个命令可以看在哪一块出了问题
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="用户管理命令" tabindex="-1"><a class="header-anchor" href="#用户管理命令" aria-hidden="true">#</a> 用户管理命令</h3><h4 id="su-切换用户" tabindex="-1"><a class="header-anchor" href="#su-切换用户" aria-hidden="true">#</a> su 切换用户</h4><p>语法：su - 用户名</p><h4 id="useradd-添加新用户" tabindex="-1"><a class="header-anchor" href="#useradd-添加新用户" aria-hidden="true">#</a> useradd 添加新用户</h4><blockquote><p>添加新用户</p></blockquote><p>语法：useradd 用户名</p><h4 id="passwd-设置用户密码" tabindex="-1"><a class="header-anchor" href="#passwd-设置用户密码" aria-hidden="true">#</a> passwd 设置用户密码</h4><blockquote><p>设置用户密码</p></blockquote><p>语法：passwd 用户名</p><h4 id="w-查看登录用户详细信息" tabindex="-1"><a class="header-anchor" href="#w-查看登录用户详细信息" aria-hidden="true">#</a> w 查看登录用户详细信息</h4><blockquote><p>查看登录用户详细信息</p></blockquote><p>语法：w</p><p><img src="https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20220621223236948.png" alt="image-20220621223236948"></p><ul><li>up表示linux连续运行的时间</li><li>load average 系统的负载情况</li><li>what 表示一个用户当前执行了什么操作，如果什么操作都没有做 就是base</li><li>JCPU、PCPU占用CPU资源的情况</li></ul><h4 id="userdel-删除帐号" tabindex="-1"><a class="header-anchor" href="#userdel-删除帐号" aria-hidden="true">#</a> userdel 删除帐号</h4><p>语法: userdel 选项 用户名</p><p>常用的选项是 <strong>-r</strong>，它的作用是把用户的主目录一起删除。</p><h4 id="usermod-修改帐号" tabindex="-1"><a class="header-anchor" href="#usermod-修改帐号" aria-hidden="true">#</a> usermod 修改帐号</h4><p>修改用户账号就是根据实际情况更改用户的有关属性，如用户号、主目录、用户组、登录Shell等。</p><p>修改已有用户的信息使用<code>usermod</code>命令，其格式如下：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>usermod 选项 用户名
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>常用的选项包括<code>-c, -d, -m, -g, -G, -s, -u以及-o等</code>，这些选项的意义与<code>useradd</code>命令中的选项一样，可以为用户指定新的资源值。</p><p>另外，有些系统可以使用选项：-l 新用户名</p><p>这个选项指定一个新的账号，即将原来的用户名改为新的用户名。</p><p>例如：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>## usermod -s /bin/ksh -d /home/z –g developer sam
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>此命令将用户sam的登录Shell修改为ksh，主目录改为/home/z，用户组改为developer。</p><h3 id="挂载命令" tabindex="-1"><a class="header-anchor" href="#挂载命令" aria-hidden="true">#</a> 挂载命令</h3><blockquote><p>相当于在linux分配一个盘符，把U盘等等的外部设备内容和该盘符（这个盘符是一个目录，在windows里是一个盘符如：H盘，i盘）连接</p></blockquote><p><strong>挂载语法</strong>: mount 名字 挂载位置</p><blockquote><p>U盘: /dev/sdb 光驱: /dev/sr0</p></blockquote><blockquote><p>如: 将U盘挂载至 mnut下的aa文件夹 mount /dev/sdb /mnt/aa</p></blockquote><p><strong>取消挂载</strong> : umount /dev/sr0</p><p>步骤:</p><ul><li>在根目录下mnt目录,一般习惯上在这个目录里面再创建一个目录用来挂载,</li><li>在根目录dev目录下可查询对应的设备</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>注意1：在根目录下有一个mnt目录，这个目录就是用来做挂载的（相当盘符），一般习惯上在这个目录里面再创建一个目录cdrom,相当创建一个盘符
注意2：设备文件名 dev/sr0 就是光驱硬件 在centos6以上的版本，光驱的设备文件名默认就是dev/sr0 ,也可以写成  dev/cdrom
注意2：在取消挂载时不能在挂载目录里取消

因为在dev目录里面的cdrom就是一个软连接，指向的就是sr0
[zhangsan@localhost ~]$ ls -ld /dev/cdrom
lrwxrwxrwx. 1 root root 3 10月 28 00:02 /dev/cdrom -&gt; sr0
挂载点就是盘符
挂载成功，就是盘符和设备硬件建立了连接
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="关机重启命令" tabindex="-1"><a class="header-anchor" href="#关机重启命令" aria-hidden="true">#</a> 关机重启命令</h3><h4 id="shutdown命令" tabindex="-1"><a class="header-anchor" href="#shutdown命令" aria-hidden="true">#</a> shutdown命令</h4><p>语法: shutdown [选项] 时间</p><p>选项： shutdown 会保存内容再关机</p><p>-c： 取消前一个关机命令 cancel</p><p>-h： 关机 halt 停止的含义</p><p>-r： 重启 reboot</p><blockquote><p>[root@localhost ~]#shutdown -h 20:30 晚上八点半关机</p><p>[root@localhost ~]#shutdown -h now 立刻关机 h:halted 停下来</p><p>[root@localhost ~]#shutdown -c 取消关机</p><p>[root@localhost cdrom]## shutdown -r now</p><p>直接拔掉电源：对于高速运转的硬盘 导致损坏</p></blockquote><p><strong>其他关机命令</strong></p><ul><li>[root@localhost ~]## halt</li><li>[root@localhost ~]## poweroff</li><li>[root@localhost ~]## init 0</li></ul><p><strong>其他重启命令</strong></p><ul><li>root@localhost ~]## reboot</li><li>[root@localhost ~]## init 6</li></ul><p><strong>系统运行级别</strong></p><ul><li>0 关机</li><li>1 单用户 类似windows开启的安全模式进入，就是启动 最小的服务 进入window操作系统，因为其他的服务导致window无法启动</li><li>2 不完全多用户不含NFS服务（network file system 它就是2个系统之间共享文件的一个服务）</li><li>3 完全多用户：完全的命令行</li><li>4 未分配</li><li>5 图形界面</li><li>6 重启</li></ul><h3 id="dos文本和unix格式转换" tabindex="-1"><a class="header-anchor" href="#dos文本和unix格式转换" aria-hidden="true">#</a> dos文本和unix格式转换</h3><h4 id="dos2unix-转linux" tabindex="-1"><a class="header-anchor" href="#dos2unix-转linux" aria-hidden="true">#</a> dos2unix 转linux</h4><p>作用：dos2unix命令：用来将DOS格式的文本文件转换成UNIX格式</p><p>语法：dos2unix 文件名</p><h4 id="unix2dos-转window" tabindex="-1"><a class="header-anchor" href="#unix2dos-转window" aria-hidden="true">#</a> unix2dos 转window</h4><p>作用：unix2dos命令：用来将unix格式的文本文件转换成dos格式</p><p>语法：unix2dos 文件名</p><h3 id="系统类命令" tabindex="-1"><a class="header-anchor" href="#系统类命令" aria-hidden="true">#</a> 系统类命令</h3><h4 id="_1、查看linux系统是多少位" tabindex="-1"><a class="header-anchor" href="#_1、查看linux系统是多少位" aria-hidden="true">#</a> 1、查看linux系统是多少位</h4><p>[oracle@localhost database]$ getconf LONG_BIT</p><h4 id="_2、linux查看操作系统内核信息" tabindex="-1"><a class="header-anchor" href="#_2、linux查看操作系统内核信息" aria-hidden="true">#</a> 2、Linux查看操作系统内核信息</h4><p>[oracle@localhost database]$ uname -a</p><p>[oracle@localhost database]$ uname -r</p><h4 id="_3、linux查看操作系统版本信息" tabindex="-1"><a class="header-anchor" href="#_3、linux查看操作系统版本信息" aria-hidden="true">#</a> 3、Linux查看操作系统版本信息</h4><blockquote><p>查看当前操作系统版本信息</p></blockquote><p>[oracle@localhost database]$ cat /proc/version</p><h3 id="wget-命令下载" tabindex="-1"><a class="header-anchor" href="#wget-命令下载" aria-hidden="true">#</a> wget 命令下载</h3><blockquote><p>wget是Linux中的一个下载文件的工具，wget是在Linux下开发的开放源代码的软件，wget工具体积小但功能完善，它支持断点下载功能，同时支持FTP和HTTP下载方式，支持代理服务器和设置起来方便简单</p><p>[root@network test]## yum install -y wget</p></blockquote><h4 id="下载保存当前目录" tabindex="-1"><a class="header-anchor" href="#下载保存当前目录" aria-hidden="true">#</a> 下载保存当前目录</h4><ul><li>语法: wget 下载地址</li></ul><blockquote><p>从网络下载一个文件并保存在当前目录</p><p>[root@network test]#wget http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-utils-2.17-55.el6.x86_64.rpm</p></blockquote><h4 id="下载重命名保存当前目录" tabindex="-1"><a class="header-anchor" href="#下载重命名保存当前目录" aria-hidden="true">#</a> 下载重命名保存当前目录</h4><ul><li>语法: wget -O 下载名字 下载地址</li></ul><blockquote><p>使用 wget -O 下载并以不同的文件名保存</p><p>[root@network test]#wget -O copr-be.rpm</p><p>http://copr-be.cloud.fedoraproject.org/results/mosquito/myrepo-el6/epel-6-x86_64/glibc-2.17-55.fc20/glibc-utils-2.17-55.el6.x86_64.rpm</p></blockquote><h4 id="断点下载" tabindex="-1"><a class="header-anchor" href="#断点下载" aria-hidden="true">#</a> 断点下载</h4><ul><li>语法: wget -c 下载地址</li></ul><blockquote><p>使用 wget -c 断点续传</p><p>使用wget -c重新启动下载中断的文件:对于我们下载大文件时突然由于网络等原因中断非常有帮助，我们可以继续接着下载而不是重新下载一个文件</p><p>[root@network test]#wget -c https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz</p></blockquote><h4 id="后台下载" tabindex="-1"><a class="header-anchor" href="#后台下载" aria-hidden="true">#</a> 后台下载</h4><ul><li>语法: wget -b 下载地址</li></ul><blockquote><p>使用 wget -b 后台下载</p><p>[root@network test]#wget -b https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz</p></blockquote><h3 id="后台运行jar包" tabindex="-1"><a class="header-anchor" href="#后台运行jar包" aria-hidden="true">#</a> 后台运行jar包</h3><blockquote><p>能够将web项目打包成的jar包放入Linxu系统并运行 使用其ip地址和端口访问程序</p></blockquote><p>语法一:</p><p>java -jar XXX.jar &amp;</p><p>nohup java -jar XXX.jar &amp;</p><ul><li>常规语法 运行指定jar包 注意是在前台运行 关闭会话即停止 会将日志存储至 nohup.out 文件内</li></ul><p>语法二:</p><p>java -jar XXX.jar --server.port=8081 &gt; demo.out &amp;</p><p>nohup java -jar XXX.jar --server.port=8081 &gt; demo.out &amp;</p><ul><li>设置访问端口 8081 和 日志的存储文件 demo.out</li></ul><h3 id="防火墙-端口" tabindex="-1"><a class="header-anchor" href="#防火墙-端口" aria-hidden="true">#</a> 防火墙 端口</h3><p>https://blog.csdn.net/wade3015/article/details/90725871</p><blockquote><p>开启指定端口 报错执行如下指令</p><p>systemctl status firewalld</p></blockquote><p>1、查看已经开放的端口</p><p>firewall-cmd --list-ports</p><p>2、开启指定端口</p><p>firewall-cmd --zone=public --add-port=8080/tcp --permanent</p><p>说明：参数--permanent永久生效，没有此参数重启后失效</p><p>2、重启防火墙</p><p>firewall-cmd --reload</p><p>3、查询指定端口是否已开</p><p>4.临时关闭防火墙</p><p>systemctl stop firewalld.service</p><p>5.关闭端口</p><p>kill -9 PID</p><p>6.开启防火墙：systemctl start firewalld</p><h3 id="查看linux运行的进程" tabindex="-1"><a class="header-anchor" href="#查看linux运行的进程" aria-hidden="true">#</a> 查看linux运行的进程</h3><p><strong>语法</strong>: ps -ef</p><h3 id="管道符" tabindex="-1"><a class="header-anchor" href="#管道符" aria-hidden="true">#</a> 管道符 |</h3><blockquote><p>可以连接两个命令 就是前一个命令的输出作为后一个命令的输入</p></blockquote><p>语法: ps -ef | grep xxx</p><ul><li>在linux运行的进程里 查询包含xxx的选项</li></ul><h2 id="vim-文本编辑器" tabindex="-1"><a class="header-anchor" href="#vim-文本编辑器" aria-hidden="true">#</a> vim -- 文本编辑器</h2><blockquote><p>Vim 是从 vi 发展出来的一个文本编辑器。代码补全、编译及错误跳转等方便编程的功能特别丰富，在程序员中被广泛使用。vim 的官方网站 (https://www.vim.org/)</p></blockquote><h3 id="vi-vim-的使用" tabindex="-1"><a class="header-anchor" href="#vi-vim-的使用" aria-hidden="true">#</a> vi/vim 的使用</h3><p>基本上 vi/vim 共分为三种模式，分别是<strong>命令模式（Command mode）</strong>，<strong>输入模式（Insert mode）<strong>和</strong>底线命令模式（Last line mode）</strong>。 这三种模式的作用分别是：</p><p>下载: yum -y install vim</p><h4 id="命令模式" tabindex="-1"><a class="header-anchor" href="#命令模式" aria-hidden="true">#</a> 命令模式：</h4><p>用户刚刚启动 vi/vim，便进入了命令模式。</p><p>此状态下敲击键盘动作会被Vim识别为命令，而非输入字符。比如我们此时按下i，并不会输入一个字符，i被当作了一个命令。</p><p>以下是常用的几个命令：</p><ul><li><strong>i</strong> 切换到输入模式，以输入字符。</li><li><strong>x</strong> 删除当前光标所在处的字符。</li><li><strong>:</strong> 切换到底线命令模式，以在最底一行输入命令。</li></ul><p>若想要编辑文本：启动Vim，进入了命令模式，按下i，切换到输入模式。</p><p>命令模式只有一些最基本的命令，因此仍要依靠底线命令模式输入更多命令。</p><h4 id="输入模式" tabindex="-1"><a class="header-anchor" href="#输入模式" aria-hidden="true">#</a> 输入模式</h4><p>在命令模式下按下i就进入了输入模式。</p><p>在输入模式中，可以使用以下按键：</p><ul><li><strong>字符按键以及Shift组合</strong>，输入字符</li><li><strong>ENTER</strong>，回车键，换行</li><li><strong>BACK SPACE</strong>，退格键，删除光标前一个字符</li><li><strong>DEL</strong>，删除键，删除光标后一个字符</li><li><strong>方向键</strong>，在文本中移动光标</li><li><strong>HOME</strong>/<strong>END</strong>，移动光标到行首/行尾</li><li><strong>Page Up</strong>/<strong>Page Down</strong>，上/下翻页</li><li><strong>Insert</strong>，切换光标为输入/替换模式，光标将变成竖线/下划线</li><li><strong>ESC</strong>，退出输入模式，切换到命令模式</li></ul><h4 id="底线命令模式" tabindex="-1"><a class="header-anchor" href="#底线命令模式" aria-hidden="true">#</a> 底线命令模式</h4><p>在命令模式下按下:（英文冒号）就进入了底线命令模式。</p><p>底线命令模式可以输入单个或多个字符的命令，可用的命令非常多。</p><p>在底线命令模式中，基本的命令有（已经省略了冒号）：</p><ul><li>q 退出程序</li><li>w 保存文件</li></ul><p>按ESC键可随时退出底线命令模式。</p><p><img src="https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20220622153611874.png" alt="image-20220622153611874"></p><h3 id="文件编辑命令" tabindex="-1"><a class="header-anchor" href="#文件编辑命令" aria-hidden="true">#</a> 文件编辑命令</h3><h4 id="插入命令" tabindex="-1"><a class="header-anchor" href="#插入命令" aria-hidden="true">#</a> 插入命令</h4><table><thead><tr><th>命令</th><th>作用</th></tr></thead><tbody><tr><td><strong>a</strong></td><td>在光标所在字符后插入</td></tr><tr><td>A</td><td>在光标所在行尾插入</td></tr><tr><td><strong>i</strong></td><td>在光标所在字符前插入</td></tr><tr><td>I</td><td>在光标所在行行首插入</td></tr><tr><td><strong>o</strong></td><td>在光标下插入新行</td></tr><tr><td>O</td><td>在光标上插入新行</td></tr></tbody></table><h4 id="定位命令" tabindex="-1"><a class="header-anchor" href="#定位命令" aria-hidden="true">#</a> 定位命令</h4><table><thead><tr><th>命令</th><th>作用</th></tr></thead><tbody><tr><td>: set nu</td><td>设置行号</td></tr><tr><td>: set nonu</td><td>取消行号</td></tr><tr><td>gg G</td><td>到第一行 到最后一行</td></tr><tr><td>nG</td><td>到第n行</td></tr><tr><td>: n</td><td>到第n行</td></tr><tr><td>$</td><td>行尾</td></tr><tr><td>0</td><td>行首</td></tr></tbody></table><h4 id="删除命令" tabindex="-1"><a class="header-anchor" href="#删除命令" aria-hidden="true">#</a> 删除命令</h4><table><thead><tr><th>命令</th><th>作用</th></tr></thead><tbody><tr><td>x</td><td>删除光标所在处字符</td></tr><tr><td>nx</td><td>删除光标所在处后n个字符</td></tr><tr><td>dd</td><td>删除光标所在行，ndd删除n行</td></tr><tr><td>dG</td><td>删除光标所在行到文件末尾内容</td></tr><tr><td>D</td><td>删除光标所在处到行尾内容</td></tr><tr><td>:n1,n2d</td><td>删除指定范围的行</td></tr></tbody></table><h4 id="复制和剪切命令" tabindex="-1"><a class="header-anchor" href="#复制和剪切命令" aria-hidden="true">#</a> 复制和剪切命令</h4><table><thead><tr><th>命令</th><th>作用</th></tr></thead><tbody><tr><td>yy</td><td>复制当前行</td></tr><tr><td>nyy</td><td>复制当前行以下n行</td></tr><tr><td>dd</td><td>剪切当前行</td></tr><tr><td>ndd</td><td>剪切当前行以下n行</td></tr><tr><td>p、P</td><td>粘贴在当前光标所在行下 或行上</td></tr></tbody></table><h4 id="替换和取消命令" tabindex="-1"><a class="header-anchor" href="#替换和取消命令" aria-hidden="true">#</a> 替换和取消命令</h4><table><thead><tr><th>命令</th><th>作用</th></tr></thead><tbody><tr><td>r</td><td>取代光标所在处字符</td></tr><tr><td>R</td><td>从光标所在处开始替换字 符，按Esc结束</td></tr><tr><td>u</td><td>取消上一步操作</td></tr></tbody></table><h4 id="搜索和搜索替换命令" tabindex="-1"><a class="header-anchor" href="#搜索和搜索替换命令" aria-hidden="true">#</a> 搜索和搜索替换命令</h4><table><thead><tr><th>命令</th><th>作用</th></tr></thead><tbody><tr><td>/string</td><td>搜索指定字符串 搜索时忽略大小写 **😗*set ic</td></tr><tr><td>n</td><td>搜索指定字符串的下一个出现位置</td></tr><tr><td>:%s/old/new/g</td><td>全文替换指定字符串</td></tr><tr><td>:1,10s/old/new/g</td><td>在一定范围内替换指定字符串 1到10行</td></tr></tbody></table><h4 id="保存和退出命令" tabindex="-1"><a class="header-anchor" href="#保存和退出命令" aria-hidden="true">#</a> 保存和退出命令</h4><table><thead><tr><th>命令</th><th>作用</th></tr></thead><tbody><tr><td>:w</td><td>保存修改</td></tr><tr><td>:w new_filename</td><td>另存为指定文件</td></tr><tr><td>:wq</td><td>保存修改并退出</td></tr><tr><td>ZZ</td><td>快捷键，保存修改并退出，在vi命令下使用</td></tr><tr><td>:q!</td><td>不保存修改退出</td></tr><tr><td>:wq!</td><td>保存修改并退出（文件所有者及root可使用）</td></tr></tbody></table><h3 id="vim使用技巧" tabindex="-1"><a class="header-anchor" href="#vim使用技巧" aria-hidden="true">#</a> Vim使用技巧</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>导入命令执行结果 <span class="token operator">:</span>r  <span class="token operator">!</span>命令

定义快捷键 <span class="token operator">:</span>map 快捷键 触发命令

范例： <span class="token operator">:</span> map <span class="token operator">^</span><span class="token class-name">P</span>   <span class="token class-name">I</span>#<span class="token generics"><span class="token punctuation">&lt;</span>ESC<span class="token punctuation">&gt;</span></span>

<span class="token operator">:</span> map    <span class="token operator">^</span><span class="token class-name">B</span> <span class="token number">0</span>x

连续行注释

<span class="token operator">:</span>n1<span class="token punctuation">,</span>n2s<span class="token operator">/</span><span class="token operator">^</span><span class="token operator">/</span>#<span class="token operator">/</span>g

<span class="token operator">:</span>n1<span class="token punctuation">,</span>n2s<span class="token operator">/</span><span class="token operator">^</span>#<span class="token comment">//g</span>

<span class="token operator">:</span>n1<span class="token punctuation">,</span>n2s<span class="token operator">/</span><span class="token operator">^</span><span class="token operator">/</span>\<span class="token operator">/</span>\<span class="token operator">/</span><span class="token operator">/</span>g
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="linux-yum-命令" tabindex="-1"><a class="header-anchor" href="#linux-yum-命令" aria-hidden="true">#</a> Linux yum 命令</h2><p>yum（ Yellow dog Updater, Modified）是一个在 Fedora 和 RedHat 以及 SUSE 中的 Shell 前端软件包管理器。</p><p>基于 RPM 包管理，能够从指定的服务器自动下载 RPM 包并且安装，可以自动处理依赖性关系，并且一次安装所有依赖的软件包，无须繁琐地一次次下载、安装。</p><p>yum 提供了查找、安装、删除某一个、一组甚至全部软件包的命令，而且命令简洁而又好记。</p><h3 id="yum-语法" tabindex="-1"><a class="header-anchor" href="#yum-语法" aria-hidden="true">#</a> yum 语法</h3><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>yum [options] [command] [package ...]
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><ul><li>**options：**可选，选项包括-h（帮助），-y（当安装过程提示选择全部为 &quot;yes&quot;），-q（不显示安装的过程）等等。</li><li>**command：**要进行的操作。</li><li>**package：**安装的包名。</li></ul><h3 id="yum常用命令" tabindex="-1"><a class="header-anchor" href="#yum常用命令" aria-hidden="true">#</a> yum常用命令</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token operator">-</span> \<span class="token number">1.</span> 列出所有可更新的软件清单命令：<span class="token operator">*</span><span class="token operator">*</span>yum check<span class="token operator">-</span>update<span class="token operator">*</span><span class="token operator">*</span>
<span class="token operator">-</span> \<span class="token number">2.</span> 更新所有软件命令：<span class="token operator">*</span><span class="token operator">*</span>yum update<span class="token operator">*</span><span class="token operator">*</span>
<span class="token operator">-</span> \<span class="token number">3.</span> 仅安装指定的软件命令：<span class="token operator">*</span><span class="token operator">*</span>yum install <span class="token generics"><span class="token punctuation">&lt;</span>package_name<span class="token punctuation">&gt;</span></span><span class="token operator">*</span><span class="token operator">*</span>
<span class="token operator">-</span> \<span class="token number">4.</span> 仅更新指定的软件命令：<span class="token operator">*</span><span class="token operator">*</span>yum update <span class="token generics"><span class="token punctuation">&lt;</span>package_name<span class="token punctuation">&gt;</span></span><span class="token operator">*</span><span class="token operator">*</span>
<span class="token operator">-</span> \<span class="token number">5.</span> 列出所有可安裝的软件清单命令：<span class="token operator">*</span><span class="token operator">*</span>yum list<span class="token operator">*</span><span class="token operator">*</span>
<span class="token operator">-</span> \<span class="token number">6.</span> 删除软件包命令：<span class="token operator">*</span><span class="token operator">*</span>yum remove <span class="token generics"><span class="token punctuation">&lt;</span>package_name<span class="token punctuation">&gt;</span></span><span class="token operator">*</span><span class="token operator">*</span>
<span class="token operator">-</span> \<span class="token number">7.</span> 查找软件包命令：<span class="token operator">*</span><span class="token operator">*</span>yum search <span class="token generics"><span class="token punctuation">&lt;</span>keyword<span class="token punctuation">&gt;</span></span><span class="token operator">*</span><span class="token operator">*</span>
<span class="token operator">-</span> \<span class="token number">8.</span> 清除缓存命令<span class="token operator">:</span>
  <span class="token operator">-</span> <span class="token operator">*</span><span class="token operator">*</span>yum clean packages<span class="token operator">*</span><span class="token operator">*</span><span class="token operator">:</span> 清除缓存目录下的软件包
  <span class="token operator">-</span> <span class="token operator">*</span><span class="token operator">*</span>yum clean headers<span class="token operator">*</span><span class="token operator">*</span><span class="token operator">:</span> 清除缓存目录下的 headers
  <span class="token operator">-</span> <span class="token operator">*</span><span class="token operator">*</span>yum clean oldheaders<span class="token operator">*</span><span class="token operator">*</span><span class="token operator">:</span> 清除缓存目录下旧的 headers
  <span class="token operator">-</span> <span class="token operator">*</span><span class="token operator">*</span>yum clean<span class="token punctuation">,</span> yum clean all <span class="token punctuation">(</span><span class="token operator">=</span> yum clean packages<span class="token punctuation">;</span> yum clean oldheaders<span class="token punctuation">)</span><span class="token operator">*</span><span class="token operator">*</span> <span class="token operator">:</span>清除缓存目录下的软件包及旧的 headers
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>netstat 网络相关信息</strong></p><blockquote><p>显示网络相关信息</p><p>yum install net-tools</p></blockquote><h2 id="nginx-分隔" tabindex="-1"><a class="header-anchor" href="#nginx-分隔" aria-hidden="true">#</a> ------------ nginx 分隔 -----------</h2><h2 id="nginx-反向代理-服务器" tabindex="-1"><a class="header-anchor" href="#nginx-反向代理-服务器" aria-hidden="true">#</a> nginx 反向代理 服务器</h2><h3 id="版本和安装" tabindex="-1"><a class="header-anchor" href="#版本和安装" aria-hidden="true">#</a> 版本和安装</h3><h4 id="window版" tabindex="-1"><a class="header-anchor" href="#window版" aria-hidden="true">#</a> window版</h4><p>从官网 <a href="http://nginx.org/en/download.html" target="_blank" rel="noopener noreferrer"><em>http://nginx.org/en/download.html</em> (opens new window)<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a>下载最新的文档版。例如：<code>nginx-1.18.0</code></p><p>解压 <em><code>nginx-1.18.0.zip</code></em> 到本地目录。按惯例，路径中不要有中文，最好不要有空格。例如：<code>D:\ProgramFiles\nginx-1.18.0</code> 。</p><p>解压后，可到看到如下内容：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>nginx-1.18.0
│── conf        配置文件目录
├── contrib
├── docs
├── html        类似 tomcat 的 webapps
├── logs        日志目录  access.log成功日志  error.log失败日志
├── temp
└── nginx.exe   启动程序
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h5 id="启动" tabindex="-1"><a class="header-anchor" href="#启动" aria-hidden="true">#</a> 启动</h5><p>启动 Nginx 的方式有 2 种：</p><ol><li>直接双击 <code>nginx.exe</code>。双击后一个黑色的弹窗一闪而过。</li><li>打开 cmd 命令窗口，切换到 nginx 解压目录下，输入命令 <code>nginx.exe</code> 或者 <code>start nginx</code> 。</li></ol><p>检查 Nginx 是否启动成功的方式也有 2 种：</p><ol><li><p>直接在浏览器地址栏输入网址 <a href="http://localhost/" target="_blank" rel="noopener noreferrer"><em>http://localhost:80</em> (opens new window)<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a>。你会看到欢迎页面。</p></li><li><p>在 cmd 命令窗口输入命令 <code>tasklist /fi &quot;imagename eq nginx.exe&quot;</code> 。你会看到类似如下页面：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>映像名称    PID     会话名      会话##   内存使用
=========== ======= =========== ======= ============
nginx.exe   17220   Console     8       7,148 K
nginx.exe   17660   Console     8       7,508 K
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></li></ol><h5 id="关闭" tabindex="-1"><a class="header-anchor" href="#关闭" aria-hidden="true">#</a> 关闭</h5><p>如果使用 cmd 命令窗口启动 nginx，关闭 cmd 窗口是<strong>不能</strong>结束 nginx 进程的。</p><p>可使用两种方法关闭 nginx：</p><ol><li>输入 <code>nginx</code> 命令：<code>nginx -s stop</code>（快速停止 nginx）或 <code>nginx -s quit</code>（完整有序的停止 nginx）。</li><li>使用 <code>taskkill</code> 命令： <code>taskkill /f /t /im nginx.exe</code></li></ol><h4 id="linux版" tabindex="-1"><a class="header-anchor" href="#linux版" aria-hidden="true">#</a> linux版</h4><blockquote><p>可看下方简洁安装步骤</p></blockquote><h5 id="环境依赖" tabindex="-1"><a class="header-anchor" href="#环境依赖" aria-hidden="true">#</a> 环境依赖</h5><p>1、需要安装gcc的环境。yum install gcc-c++</p><p>2、第三方的开发包。</p><p>PCRE:PCRE(Perl Compatible Regular Expressions)是一个Perl库，包括 perl 兼容的正则表达式库。nginx的http模块使用pcre来解析正则表达式，所以需要在linux上安装pcre库。pcre-devel是使用pcre开发的一个二次开发库。nginx也需要此库。</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>yum <span class="token function">install</span> <span class="token parameter variable">-y</span> pcre pcre-devel
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>zlib:zlib库提供了很多种压缩和解压缩的方式，nginx使用zlib对http包的内容进行gzip，所以需要在linux上安装zlib库。</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>yum <span class="token function">install</span> <span class="token parameter variable">-y</span> zlib zlib-devel
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>openssl: OpenSSL 是一个强大的安全套接字层密码库，囊括主要的密码算法、常用的密钥和证书封装管理功能及SSL协议，并提供丰富的应用程序供测试或其它目的使用。nginx不仅支持http协议，还支持https（即在ssl协议上传输http），所以需要在linux安装openssl库。</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>yum <span class="token function">install</span> <span class="token parameter variable">-y</span> openssl openssl-devel
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h5 id="安装步骤" tabindex="-1"><a class="header-anchor" href="#安装步骤" aria-hidden="true">#</a> 安装步骤</h5><p>把nginx的源码包上传到linux系统</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">## tar zxvf nginx-1.8.0.tar.gz</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>使用configure命令创建一makeFile文件</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>./configure <span class="token punctuation">\</span>
<span class="token parameter variable">--prefix</span><span class="token operator">=</span>/usr/local/nginx <span class="token punctuation">\</span>
--pid-path<span class="token operator">=</span>/var/run/nginx/nginx.pid <span class="token punctuation">\</span>
--lock-path<span class="token operator">=</span>/var/lock/nginx.lock <span class="token punctuation">\</span>
--error-log-path<span class="token operator">=</span>/var/log/nginx/error.log <span class="token punctuation">\</span>
--http-log-path<span class="token operator">=</span>/var/log/nginx/access.log <span class="token punctuation">\</span>
--with-http_gzip_static_module <span class="token punctuation">\</span>
--http-client-body-temp-path<span class="token operator">=</span>/var/temp/nginx/client <span class="token punctuation">\</span>
--http-proxy-temp-path<span class="token operator">=</span>/var/temp/nginx/proxy <span class="token punctuation">\</span>
--http-fastcgi-temp-path<span class="token operator">=</span>/var/temp/nginx/fastcgi <span class="token punctuation">\</span>
--http-uwsgi-temp-path<span class="token operator">=</span>/var/temp/nginx/uwsgi <span class="token punctuation">\</span>
--http-scgi-temp-path<span class="token operator">=</span>/var/temp/nginx/scgi
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>注意：启动nginx之前，上边将临时文件目录指定为/var/temp/nginx，需要在/var下创建temp及nginx目录</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost sbin<span class="token punctuation">]</span><span class="token comment">## mkdir  -p  /var/temp/nginx/client </span>
<span class="token punctuation">[</span>root@localhost sbin<span class="token punctuation">]</span><span class="token comment">#make</span>
<span class="token punctuation">[</span>root@localhost sbin<span class="token punctuation">]</span><span class="token comment">#make install</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h5 id="启动-nginx" tabindex="-1"><a class="header-anchor" href="#启动-nginx" aria-hidden="true">#</a> 启动 nginx</h5><blockquote><p>注意: 安装完成的源目录是在 /usr/local/nginx/sbin 里 并不是安装包的位置</p></blockquote><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>进入sbin目录
<span class="token punctuation">[</span>root@localhost sbin<span class="token punctuation">]</span><span class="token comment">## ./nginx </span>
关闭nginx：
<span class="token punctuation">[</span>root@localhost sbin<span class="token punctuation">]</span><span class="token comment">## ./nginx -s stop</span>
推荐使用：
<span class="token punctuation">[</span>root@localhost sbin<span class="token punctuation">]</span><span class="token comment">## ./nginx -s quit</span>
重启nginx：
<span class="token number">1</span>、先关闭后启动。
<span class="token number">2</span>、刷新配置文件：
<span class="token punctuation">[</span>root@localhost sbin<span class="token punctuation">]</span><span class="token comment">## ./nginx -s reload</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h5 id="访问-nginx" tabindex="-1"><a class="header-anchor" href="#访问-nginx" aria-hidden="true">#</a> 访问 nginx</h5><p>默认是80端口。注意：是否关闭防火墙。</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost sbin]</span><span class="token comment">## systemctl stop firewalld.service</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="nginx配置文件" tabindex="-1"><a class="header-anchor" href="#nginx配置文件" aria-hidden="true">#</a> nginx配置文件</h3><p>在 nginx.conf 的注释符号为： #；每个指令必须有分号结束</p><p>1.全局块</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token comment">#user  nobody;</span>
worker_processes  <span class="token number">1</span><span class="token punctuation">;</span>

<span class="token comment">#error_log  logs/error.log;</span>
<span class="token comment">#error_log  logs/error.log  notice;</span>
<span class="token comment">#error_log  logs/error.log  info;</span>

<span class="token comment">#pid        logs/nginx.pid;</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>#user nobody; 表示配置用户，默认用户为nobody（nobody表示任何用户），该指令的作用是哪些用户可以启动worker进程。nginx在启动后是有多个进程相互协助工作的，默认是一个master主进程和一个worker工作进程。其中主进程负责接收客户端的请求，worker进程负责处理请求，响应结果。你也可以把前面的注释去掉，写上一个具体的用户 user root</p><p>worker_processes：工作进程的个数，默认为1，一般来说会设置成cpu核数的2倍；如果你设置一个数值为3，那么nginx在启动的时候会有3个workder进程和一个master主进程</p><p>error_log：nginx的日志级别配置， 默认为cri，级别从低到高为debug, info, notice, warn, error, crit ；如果你要调成notice日志级别，只要#error_log logs/error.log notice;前面的注释去掉即可，日志位置在安装nginx的时候就已经指定</p><p>pid：指定nginx进程运行文件存放地址</p></blockquote><p>2.events块</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>events <span class="token punctuation">{</span>
	accept_mutex on<span class="token punctuation">;</span>   <span class="token comment">#设置网路连接序列化，防止惊群现象发生，默认为on</span>
	multi_accept on<span class="token punctuation">;</span>  <span class="token comment">#设置一个进程是否同时接受多个网络连接，默认为off</span>
    worker_connections  1024<span class="token punctuation">;</span>  <span class="token comment">#每个worker进程最大连接数，这个值最大可设置为：65535</span>
<span class="token punctuation">}</span>
<span class="token comment">##惊群现象：一个网路连接到来，多个睡眠的进程被同时叫醒，但只有一个进程能获得链接，这样会影响系统性能</span>
<span class="token comment">##单台nginx最大连接数为 worker_processes*worker_connections</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>3.http块</p><p>可以嵌套多个server，配置代理，缓存，日志定义等绝大多数功能和第三方模块的配置</p><p>4.server块</p><p>配置虚拟主机的相关参数，一个http中可以有多个server</p><p>5.location块</p><p>配置请求的路由，以及各种页面的处理情况</p><h3 id="配置虚拟主机" tabindex="-1"><a class="header-anchor" href="#配置虚拟主机" aria-hidden="true">#</a> 配置虚拟主机</h3><p>就是在一台服务器启动多个网站。如何区分不同的网站：</p><p>1、域名不同</p><p>2、端口不同</p><h4 id="通过端口区分不同虚拟机" tabindex="-1"><a class="header-anchor" href="#通过端口区分不同虚拟机" aria-hidden="true">#</a> 通过端口区分不同虚拟机</h4><h5 id="打开nginx的配置文件" tabindex="-1"><a class="header-anchor" href="#打开nginx的配置文件" aria-hidden="true">#</a> 打开Nginx的配置文件：</h5><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost nginx<span class="token punctuation">]</span><span class="token comment">## vim  conf/nginx.conf</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>server <span class="token punctuation">{</span>
    listen       <span class="token number">80</span><span class="token punctuation">;</span>
    server_name  localhost<span class="token punctuation">;</span>
    <span class="token comment">#charset koi8-r;</span>
    <span class="token comment">#access_log  logs/host.access.log  main;</span>
    location / <span class="token punctuation">{</span>
    root   html<span class="token punctuation">;</span>
    index  index.html index.htm<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>说明：一个server节点就是一个虚拟主机，html是nginx安装目录下的html目录(静态页面存放的位置,也可以使用绝对路径)，可以配置多个server，配置了多个虚拟主机</p></blockquote><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code> server <span class="token punctuation">{</span>
        listen       81<span class="token punctuation">;</span>
        server_name  localhost<span class="token punctuation">;</span>
        <span class="token comment">#charset koi8-r;</span>
        <span class="token comment">#access_log  logs/host.access.log  main;</span>
        location <span class="token operator">/</span> <span class="token punctuation">{</span>
            root   html-81<span class="token punctuation">;</span>
            index  index<span class="token punctuation">.</span>html index<span class="token punctuation">.</span>htm<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h5 id="重新加载配置文件" tabindex="-1"><a class="header-anchor" href="#重新加载配置文件" aria-hidden="true">#</a> 重新加载配置文件</h5><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost nginx]</span><span class="token comment">## sbin/nginx -s reload</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>注意: <strong>一定要关闭防火墙</strong></p><h4 id="通过域名区分虚拟主机" tabindex="-1"><a class="header-anchor" href="#通过域名区分虚拟主机" aria-hidden="true">#</a> 通过域名区分虚拟主机</h4><h5 id="什么是域名" tabindex="-1"><a class="header-anchor" href="#什么是域名" aria-hidden="true">#</a> <strong>什么是域名</strong></h5><p>域名就是网站。如www.baidu.com www.taobao.com <a href="http://www.jd.com" target="_blank" rel="noopener noreferrer">www.jd.com<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></p><p>dns服务器：把域名解析为ip地址。保存的就是域名和ip的映射关系</p><p>一级域名：一串字符串中间一个点隔开，例如baidu.com。是互联网DNS等级之中的最高级的域，它保存于DNS根域的名字空间中</p><p>二级域名：是一个一级域名以下的主机名，一串字符串中间两个“.”隔开，例如www.baidu.com。二级域名就是最靠近顶级域名左侧的字段</p><p>三级域名：二级域名的子域名，特征是包含三个“.”，例如___.___.baidu.com ，___上可以填写任意内容，都属于三级域名</p><p>我们接触的顶级域名(一级域名)又分为两类：一是国家和地区顶级域名，例如中国是cn；二是国际顶级域名，例如表示工商企业的.com，表示非盈利组织的.org，表示网络商的.net，edu为学校单位，.gov为政府机构等</p><p>一个域名对应一个ip地址，一个ip地址可以被多个域名绑定。</p><p>实验1：</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>修改window的hosts文件：（C:\Windows\System32\drivers\etc）
注意：该文件如果配置域名和ip的映射关系，如果hosts文件中配置了域名和ip的对应关系，不需要走dns服务器。
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>128<span class="token punctuation">.</span>129 www<span class="token punctuation">.</span>jd<span class="token punctuation">.</span>com
192<span class="token punctuation">.</span>168<span class="token punctuation">.</span>128<span class="token punctuation">.</span>129 www<span class="token punctuation">.</span>163<span class="token punctuation">.</span>com
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>注意：如果修改后映射不生效，可参考以下解决办法：</p><p>1.该文件保存时未使用ansi编码进行保存，解决办法：更改文件编码为ansi进行保存</p><p>2.启用了DNS Client服务（该服务为DNS解析的缓存服务）解决办法：将该服务停用；如果该服务为自动启用，请改为手动启用</p><h5 id="nginx的配置" tabindex="-1"><a class="header-anchor" href="#nginx的配置" aria-hidden="true">#</a> <strong>Nginx的配置</strong></h5><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>server <span class="token punctuation">{</span>
        listen       80<span class="token punctuation">;</span>
        server_name  www<span class="token punctuation">.</span>jd<span class="token punctuation">.</span>com<span class="token punctuation">;</span>
        <span class="token comment">#charset koi8-r;</span>
        <span class="token comment">#access_log  logs/host.access.log  main;</span>
        location <span class="token operator">/</span> <span class="token punctuation">{</span>
            root   html-jd<span class="token punctuation">;</span>
            index  index<span class="token punctuation">.</span>html index<span class="token punctuation">.</span>htm<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
 server <span class="token punctuation">{</span>
        listen       80<span class="token punctuation">;</span>
        server_name  www<span class="token punctuation">.</span>163<span class="token punctuation">.</span>com<span class="token punctuation">;</span>
        <span class="token comment">#charset koi8-r;</span>
        <span class="token comment">#access_log  logs/host.access.log  main;</span>
        location <span class="token operator">/</span> <span class="token punctuation">{</span>
            root   html-163<span class="token punctuation">;</span>
            index  index<span class="token punctuation">.</span>html index<span class="token punctuation">.</span>htm<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="反向代理" tabindex="-1"><a class="header-anchor" href="#反向代理" aria-hidden="true">#</a> 反向代理</h2><p>正向代理：如果把局域网外的Internet想象成一个巨大的资源库,则局域网中的客户端要访问Internet ,则需要通过代理服务器来访问,这种代理服务就称为正向代理。代理的是客户端</p><p>反向代理：其实客户端对代理是无感知的,因为喜户端不需要任何配置就可以访问,我们只需要将请求发送到反向代理服务器,由反向代理服务器去选择目标服务器获取数据后,再返回给客户端,此时反向代理服务器和目标服务器对外就是一个服务器 ,暴露的是代理服务器地址,隐藏了真实服务器IP地址。代理的是服务器</p><blockquote><p>在这种情况下，在客户端看来，<code>Nginx</code> + <code>服务端</code> 整体扮演了一个更大意义上的服务端的概念。</p></blockquote><h3 id="案例" tabindex="-1"><a class="header-anchor" href="#案例" aria-hidden="true">#</a> 案例</h3><p>1、后端工程：把一个springboot工程2个打包，分别指定运行端口8080和8081，在linux运行起来</p><p>springboot工程：</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@RestController</span>
<span class="token keyword">public</span> <span class="token keyword">class</span> <span class="token class-name">HelloController</span> <span class="token punctuation">{</span>

    <span class="token annotation punctuation">@Value</span><span class="token punctuation">(</span><span class="token string">&quot;${server.port}&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">private</span> <span class="token class-name">String</span> port<span class="token punctuation">;</span>

    <span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/hello&quot;</span><span class="token punctuation">)</span>
    <span class="token keyword">public</span> <span class="token class-name">String</span> <span class="token function">hello1</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token string">&quot;hello&quot;</span><span class="token operator">+</span>port<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
运行端口<span class="token number">8080</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>2、nginx配置</p><div class="language-xml line-numbers-mode" data-ext="xml"><pre class="language-xml"><code>server {
    listen       80;
    server_name  www.woniu.com;
 
    location /api {
        proxy_pass  http://127.0.0.1:8080;
        rewrite &quot;^/api/(.*)$&quot; /$1 break;  
    } 
 	location / {
         root   html;
         index  index.html index.htm;
     }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    } 
} 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>说明：当我们访问www.woniu.com时，默认请求nginx里面的html目录的index.html.当我们请求www.woniu.com/api/hello时，由于以/api开头，则匹配第一个location，然后去请求http://127.0.0.1:8080这个服务器，那么问题来了，nginx转发的请求是http://127.0.0.1:8080/api/hello还是http://127.0.0.1:8080/api</p><p>这里就要注意转发规则：大家可以看看这句话： rewrite &quot;^/user/(.*)$&quot; /$1 break; 也就是路径重写 $1代表第一个（）里面的内容，如果有第二.....多个括号，则同样的用$2.....表示即可，这个正则表达式意思是说 以 api开头的被替换成/,( )里面的内容就是用$1占位符来表示，变相的把api截掉了</p></blockquote><h2 id="负载均衡" tabindex="-1"><a class="header-anchor" href="#负载均衡" aria-hidden="true">#</a> 负载均衡</h2><p>负载均衡（load balance）就是将负载分摊到多个操作单元上执行，从而提高服务的可用性和响应速度，带给用户更好的体验</p><h3 id="负载均衡的配置" tabindex="-1"><a class="header-anchor" href="#负载均衡的配置" aria-hidden="true">#</a> 负载均衡的配置</h3><p>通过 Nginx 中的 <strong>upstream</strong> 指令可以实现负载均衡，再该指令中能够配置负载均衡服务器组</p><p>目前负载均衡有 4 种典型的配置方式。分别是：</p><table><thead><tr><th style="text-align:center;">##</th><th style="text-align:left;">负载均衡方式</th><th style="text-align:left;">特点</th></tr></thead><tbody><tr><td style="text-align:center;">1</td><td style="text-align:left;">轮询方式</td><td style="text-align:left;">默认方式。每个请求按照时间顺序逐一分配到不同的后端服务器进行处理。如果有服务器宕机，会自动删除。</td></tr><tr><td style="text-align:center;">2</td><td style="text-align:left;">权重方式</td><td style="text-align:left;">利用 weight 指定轮循的权重比率，与访问率成正比。用于后端服务器性能不均衡的情况。</td></tr><tr><td style="text-align:center;">3</td><td style="text-align:left;">ip_hash 方法</td><td style="text-align:left;">每个请求按照访问 IP 的 hash 结果分配，这样可以使每个方可固定一个后端服务器，可以解决 Session 共享问题。</td></tr><tr><td style="text-align:center;">4</td><td style="text-align:left;">第三方模块</td><td style="text-align:left;">取决于所采用的第三方模块的分配规则。</td></tr></tbody></table><p>在 upstream 指定的服务器组中，若每个服务器的权重都设置为 1（默认值）时，表示当前的负载均衡是一般轮循方式</p><h4 id="准备工作" tabindex="-1"><a class="header-anchor" href="#准备工作" aria-hidden="true">#</a> 准备工作</h4><p>编写后台（SpringBoot）项目，简单起见，以占用不同的端口的形式启动 2 次，并在返回的信息中返回各自所占用的端口号</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token annotation punctuation">@Value</span><span class="token punctuation">(</span><span class="token string">&quot;${server.port}&quot;</span><span class="token punctuation">)</span>
<span class="token class-name">String</span> port<span class="token punctuation">;</span>

<span class="token annotation punctuation">@RequestMapping</span><span class="token punctuation">(</span><span class="token string">&quot;/api/hello&quot;</span><span class="token punctuation">)</span>
<span class="token keyword">public</span> <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> <span class="token function">index</span><span class="token punctuation">(</span><span class="token class-name">HttpServletRequest</span> request<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> map <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">HashMap</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token punctuation">&gt;</span></span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    map<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;code&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;10086&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    map<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;msg&quot;</span><span class="token punctuation">,</span> <span class="token string">&quot;success&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    map<span class="token punctuation">.</span><span class="token function">put</span><span class="token punctuation">(</span><span class="token string">&quot;data&quot;</span><span class="token punctuation">,</span> <span class="token keyword">this</span><span class="token punctuation">.</span>port<span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token keyword">return</span> map<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="负载方式" tabindex="-1"><a class="header-anchor" href="#负载方式" aria-hidden="true">#</a> 负载方式</h3><h5 id="_6-3-1-轮询" tabindex="-1"><a class="header-anchor" href="#_6-3-1-轮询" aria-hidden="true">#</a> 6.3.1 轮询</h5><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>upstream xxx <span class="token punctuation">{</span>
    server 127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1:8080<span class="token punctuation">;</span>
    server 127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1:9090<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
upstream yyy <span class="token punctuation">{</span>
    server 127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1:<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">;</span>
    server 127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1:<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
server <span class="token punctuation">{</span>
    <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    location <span class="token operator">/</span>api <span class="token punctuation">{</span>
        proxy_pass http:<span class="token operator">/</span><span class="token operator">/</span>xxx<span class="token punctuation">;</span>
        <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token punctuation">}</span>
    location <span class="token operator">/</span>user <span class="token punctuation">{</span>
        proxy_pass http:<span class="token operator">/</span><span class="token operator">/</span>yyy<span class="token punctuation">;</span>
        <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>上述的配置中有 2 点需要注意的：</p><p>1、<strong>upstream</strong> 配置项在 <strong>http</strong> 配置项内，但是在 <strong>server</strong> 配置项外，它们 3 者整体结构如下（不要写错地方了）：</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>http <span class="token punctuation">{</span>
    <span class="token comment">## 它们两者平级</span>
    server <span class="token punctuation">{</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token punctuation">}</span>
    upstream <span class="token punctuation">{</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>2、你所配置的 <strong>upstream</strong> 的 name 是自定义的，但是不要出现 <strong><code>-</code></strong> 号，否则会和 tomcat 有冲突。</p><p>测试：你持续访问 <code>http://127.0.0.1/api/hello</code> 你会发现页面的内容会是交替出现 <code>8080</code> 端口和 <code>9090</code> 端口</p><h5 id="_6-3-2-加权轮询" tabindex="-1"><a class="header-anchor" href="#_6-3-2-加权轮询" aria-hidden="true">#</a> 6.3.2 加权轮询</h5><p>加权轮循就是在轮循的基础上，为每个单点加上权值。权值越重的单点，承担的访问量自然也就越大。</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>upstream xxx <span class="token punctuation">{</span>
    server 127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1:8080 weight=1<span class="token punctuation">;</span>
    server 127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1:9090 weight=2<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>按照上述配置，<code>9090</code> 端口的服务将承担 2/3 的访问量，而 <code>8080</code> 端口则承担 1/3 的访问量。</p><p>将配置改为上述样子并重启 Nginx 后，再持续访问 <code>http://127.0.0.1/api/hello</code> 你会发现 <code>8080</code> 端口和 <code>9090</code> 端口会以 <code>1-2-1-2-...</code> 的次数交替出现。</p><p>除了 <strong>weight</strong> 外，常见的状态参数还有：</p><table><thead><tr><th style="text-align:left;">配置方式</th><th style="text-align:left;">说明</th></tr></thead><tbody><tr><td style="text-align:left;">max_fails</td><td style="text-align:left;">允许请求失败次数，默认为 1 。通常和下面的 fail_timeout 连用。</td></tr><tr><td style="text-align:left;">fail_timeout</td><td style="text-align:left;">在经历了 max_fails 次失败后，暂停服务的时长。这段时间内，这台服务器 Nginx 不会请求这台 Server</td></tr><tr><td style="text-align:left;">backup</td><td style="text-align:left;">预留的备份机器。它只有在其它非 backup 机器出现故障时或者忙碌的情况下，才会承担负载任务。</td></tr><tr><td style="text-align:left;">down</td><td style="text-align:left;">表示当前的 server 不参与负载均衡。</td></tr></tbody></table><p>例如：</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>upstream web_server {
    server 192.168.78.128 weight=1 max_fails=1 fail_timeout=30s;
    server 192.168.78.200 weight=2 max_fails=1 fail_timeout=30s;
    server 192.168.78.201 backup;
    server 192.168.78.210 down;
}
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h5 id="_6-3-3-ip-hash-负载" tabindex="-1"><a class="header-anchor" href="#_6-3-3-ip-hash-负载" aria-hidden="true">#</a> 6.3.3 ip_hash 负载</h5><p>ip_hash 方式的负载均衡，是将每个请求按照访问 IP 的 hash 结果分配，这样就可以使来自同一个 IP 的客户端固定访问一台 Web 服务器，从而就解决了 Session 共享问题</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>upstream xxx <span class="token punctuation">{</span>
    ip_hash<span class="token punctuation">;</span>
    server 127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1:8080<span class="token punctuation">;</span>
    server 127<span class="token punctuation">.</span>0<span class="token punctuation">.</span>0<span class="token punctuation">.</span>1:9090<span class="token punctuation">;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>使用上例配置后，你会发现无论你请求多少次 <code>http://127.0.0.1/api/hello</code> 你所看到的端口始终是 <code>8080</code> 和 <code>9090</code> 中的某一个。</p><h3 id="将客户端浏览器的-ip-传递到后台" tabindex="-1"><a class="header-anchor" href="#将客户端浏览器的-ip-传递到后台" aria-hidden="true">#</a> 将客户端浏览器的 IP 传递到后台</h3><p>对于后台而言，它所面对的『<strong>客户端</strong>』就是 Nginx，后台看不见『<strong>客户端</strong>』浏览器。这就意味着，你如果你需要在后台获取客户端浏览器的 IP 地址，你需要明确指出让 Nginx 『<strong>额外地多携带</strong>』一些数据。</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>location <span class="token operator">/</span>api <span class="token punctuation">{</span>
    proxy_pass http:<span class="token operator">/</span><span class="token operator">/</span>xxx/api<span class="token punctuation">;</span>
    proxy_set_header X-Real-IP <span class="token variable">$remote_addr</span><span class="token punctuation">;</span>

    <span class="token comment">## proxy_set_header Cookie $http_cookie;</span>
    <span class="token comment">## proxy_set_header Host $http_host;</span>
    <span class="token comment">## proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>在 Spring Boot 的 Controller 中你有 2 种方式来获得这个额外的信息：</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token keyword">public</span> <span class="token class-name">Map</span><span class="token generics"><span class="token punctuation">&lt;</span><span class="token class-name">String</span><span class="token punctuation">,</span> <span class="token class-name">String</span><span class="token punctuation">&gt;</span></span> <span class="token function">index</span><span class="token punctuation">(</span>
        <span class="token class-name">HttpServletRequest</span> request<span class="token punctuation">,</span>
        <span class="token annotation punctuation">@RequestHeader</span><span class="token punctuation">(</span><span class="token string">&quot;X-Real-IP&quot;</span><span class="token punctuation">)</span> <span class="token class-name">String</span> realIP2<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token class-name">String</span> realIP1 <span class="token operator">=</span> request<span class="token punctuation">.</span><span class="token function">getHeader</span><span class="token punctuation">(</span><span class="token string">&quot;X-Real-IP&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="nginx解决前后端跨域-了解" tabindex="-1"><a class="header-anchor" href="#nginx解决前后端跨域-了解" aria-hidden="true">#</a> nginx解决前后端跨域(了解)</h3><p>Spring Boot 不提供任何动态页面、资源，只提供 JSON 格式数据</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>http <span class="token punctuation">{</span>
    include       mime<span class="token punctuation">.</span>types<span class="token punctuation">;</span>
    default_type  application/octet-stream<span class="token punctuation">;</span>
    sendfile        on<span class="token punctuation">;</span>
    keepalive_timeout  65<span class="token punctuation">;</span>  <span class="token comment">## TCP 连接存活 65 秒</span>
    server <span class="token punctuation">{</span>
        <span class="token comment">## Nginx 监听 localhost:80 端口</span>
        listen       80<span class="token punctuation">;</span>
        server_name  localhost<span class="token punctuation">;</span>

        <span class="token comment">## 访问 URI 根路径时，返回 Nginx 根目录下的 html 目录下的 index.html 或 index.htm</span>
        location <span class="token operator">/</span> <span class="token punctuation">{</span>
            root   html<span class="token punctuation">;</span>
            index  index<span class="token punctuation">.</span>html index<span class="token punctuation">.</span>htm<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">## URI 路径以 /api 开头的将转交给『别人』处理</span>
        location <span class="token operator">/</span>api <span class="token punctuation">{</span>
            proxy_pass http:<span class="token operator">/</span><span class="token operator">/</span>localhost:8080/api<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>

        <span class="token comment">## 出现 500、502、503、504 错误时，返回 Nginx 根目录下的 html 目录下的 50x.html 。</span>
        error_page   500 502 503 504  <span class="token operator">/</span>50x<span class="token punctuation">.</span>html<span class="token punctuation">;</span>    
        location = <span class="token operator">/</span>50x<span class="token punctuation">.</span>html <span class="token punctuation">{</span>
            root   html<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>index.html内容，放nginx运行</p><div class="language-html line-numbers-mode" data-ext="html"><pre class="language-html"><code><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h2</span><span class="token punctuation">&gt;</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h2</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>./js/jquery-1.11.3.js<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">type</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">&quot;</span>text/javascript<span class="token punctuation">&quot;</span></span><span class="token punctuation">&gt;</span></span><span class="token script"><span class="token language-javascript">
$<span class="token punctuation">.</span><span class="token function">ajax</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token literal-property property">url</span><span class="token operator">:</span> <span class="token string">&#39;http://192.168.128.128:80/api/hello&#39;</span><span class="token punctuation">,</span> <span class="token comment">// 注意这里的 URL</span>
  <span class="token literal-property property">type</span><span class="token operator">:</span> <span class="token string">&quot;POST&quot;</span><span class="token punctuation">,</span>
  <span class="token function-variable function">success</span><span class="token operator">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">result</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">$</span><span class="token punctuation">(</span><span class="token string">&quot;h2&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">html</span><span class="token punctuation">(</span><span class="token string">&quot;跨域访问成功:&quot;</span> <span class="token operator">+</span> result<span class="token punctuation">.</span>data<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span><span class="token punctuation">,</span>
  <span class="token function-variable function">error</span><span class="token operator">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span><span class="token parameter">data</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token function">$</span><span class="token punctuation">(</span><span class="token string">&quot;h2&quot;</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">html</span><span class="token punctuation">(</span><span class="token string">&quot;跨域失败!!&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
</span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">&gt;</span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">&gt;</span></span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>首先当我们访问192.168.128.128时。显示index.html首页内容。在首页加载时异步请求http://127.0.0.1:80/api/hello的请求，被Nginx 接收后，Nginx 会『帮』我们去访问 http://127.0.0.1:8080<code>的</code>/api/hello，并将结果再返回给客户端了浏览器</p><h3 id="nginx搭建文件服务器" tabindex="-1"><a class="header-anchor" href="#nginx搭建文件服务器" aria-hidden="true">#</a> nginx搭建文件服务器</h3><p>安装好nginx之后，做相关配置</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>server <span class="token punctuation">{</span>
        listen       <span class="token number">80</span><span class="token punctuation">;</span>
        server_name  localhost<span class="token punctuation">;</span> 
        location / <span class="token punctuation">{</span>
	    root   /opt/soft/<span class="token punctuation">;</span> <span class="token comment">#可以在这个目录放置一些软件包，供别人下载</span>
	    autoindex on<span class="token punctuation">;</span>             <span class="token comment">#开启索引功能  这句话很重要</span>
        autoindex_exact_size off<span class="token punctuation">;</span> <span class="token comment">## 关闭计算文件确切大小（单位bytes），只显示大概大小（单位kb、mb、gb）</span>
        autoindex_localtime on<span class="token punctuation">;</span>   <span class="token comment">## 显示本机时间而非 GMT 时间</span>
        charset utf-8<span class="token punctuation">;</span> <span class="token comment">## 避免中文乱码 </span>
        <span class="token comment">## root html;</span>
        <span class="token comment">## index  index.html index.htm;</span>
        <span class="token punctuation">}</span> 
    <span class="token punctuation">}</span> 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>测试：192.172.0.11</p><h2 id="docker-分隔" tabindex="-1"><a class="header-anchor" href="#docker-分隔" aria-hidden="true">#</a> ----------- Docker 分隔 -----------</h2><h2 id="docker-容器引擎" tabindex="-1"><a class="header-anchor" href="#docker-容器引擎" aria-hidden="true">#</a> Docker 容器引擎</h2><h3 id="nacos-的下载和安装" tabindex="-1"><a class="header-anchor" href="#nacos-的下载和安装" aria-hidden="true">#</a> Nacos 的下载和安装</h3><p>首先去 nacos 的 github 地址下载 release 安装包。<a href="https://github.com/alibaba/nacos/releases" target="_blank" rel="noopener noreferrer">下载地址<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></p><p>进入到 nacos/bin 目录下面，<strong>startup</strong> 命令用于启动 nacos ，<strong>shutdown</strong> 命令用于停掉 nacos 。</p><ul><li><p>如果你是 windows 系统</p><p>执行 <strong>startup.cmd -m standalone</strong> 启动，单模式启动</p></li><li><p>如果你是 linux/unix 系统</p><p>执行 <strong>startup.sh -m standalone</strong> 启动。</p></li><li><p>如果你使用的是 docker-compose</p><p>编写docker-compose.yml文件 启动该文件 命令： docker-compose up</p><div class="language-yaml line-numbers-mode" data-ext="yml"><pre class="language-yaml"><code><span class="token key atrule">nacos</span><span class="token punctuation">:</span>
  <span class="token key atrule">image</span><span class="token punctuation">:</span> nacos/nacos<span class="token punctuation">-</span>server<span class="token punctuation">:</span>latest
  <span class="token key atrule">container_name</span><span class="token punctuation">:</span> nacos<span class="token punctuation">-</span>standalone<span class="token punctuation">-</span><span class="token number">8848</span>
  <span class="token key atrule">environment</span><span class="token punctuation">:</span>
    <span class="token punctuation">-</span> PREFER_HOST_MODE=hostname
    <span class="token punctuation">-</span> MODE=standalone   <span class="token comment">#单机模式启动</span>
  <span class="token key atrule">volumes</span><span class="token punctuation">:</span>
    <span class="token punctuation">-</span> ./8848/logs/<span class="token punctuation">:</span>/home/nacos/logs   <span class="token comment">#前面是宿主机名  后面是容器目录名</span>
    <span class="token punctuation">-</span> ./8848/init.d/custom.properties<span class="token punctuation">:</span>/home/nacos/init.d/custom.properties
  <span class="token key atrule">ports</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> <span class="token string">&quot;8848:8848&quot;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></li></ul><p>nacos 的默认服务端口是 <strong>8848</strong> ，启动完成之后通过浏览器访问 nacos：http://127.0.0.1:8848/nacos 。</p><h3 id="docker-概念" tabindex="-1"><a class="header-anchor" href="#docker-概念" aria-hidden="true">#</a> docker 概念</h3><blockquote><p>1、Docker 是一个开源的应用容器引擎 2、诞生于 2013 年初，基于 Go 语言实现， dotCloud 公司出品（后改名为Docker Inc） 3、Docker 是一个可以让开发者打包他们的应用以及依赖包到一个轻量级、可移植的容器引擎（好比汽车发动机），然后发布到任何流行的 Linux 机器上。 4、容器是完全使用沙箱机制，相互隔离 5、容器性能开销极低。 6、Docker 从 17.03 版本之后分为 CE（Community Edition: 社区版） 和 EE（Enterprise Edition: 企业版）</p></blockquote><h4 id="安装docker" tabindex="-1"><a class="header-anchor" href="#安装docker" aria-hidden="true">#</a> 安装docker</h4><p>Docker可以运行在MAC、Windows、CentOS、UBUNTU等操作系统上，本课程基于CentOS 7 安装Docker。 官网：https://www.docker.com</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token comment">## yum 包更新到最新</span>
yum update <span class="token parameter variable">-y</span>    
<span class="token comment">## 安装需要的软件包</span>
yum <span class="token function">install</span> <span class="token parameter variable">-y</span> yum-utils device-mapper-persistent-data lvm2
<span class="token comment">## 设置yum源</span>
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
<span class="token comment">## 华为的镜像服务器 可提高下载速度</span>
<span class="token function">sudo</span> <span class="token function">sed</span> <span class="token parameter variable">-i</span> <span class="token string">&#39;s+download.docker.com+repo.huaweicloud.com/docker-ce+&#39;</span> /etc/yum.repos.d/docker-ce.repo
<span class="token comment">## 安装docker</span>
yum <span class="token function">install</span> <span class="token parameter variable">-y</span> docker-ce   
<span class="token comment">## 查看docker版本，验证是否验证成功</span>
<span class="token function">docker</span> <span class="token parameter variable">-v</span>        
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>考虑到从 docker 官方的仓库下载 docker-ce 有时会比较慢，可以使用下述命令将下载网址改为华为的镜像服务器： sudo sed -i &#39;s+download.docker.com+repo.huaweicloud.com/docker-ce+&#39; /etc/yum.repos.d/docker-ce.repo</p></blockquote><h4 id="docker相关概念" tabindex="-1"><a class="header-anchor" href="#docker相关概念" aria-hidden="true">#</a> docker相关概念</h4><ul><li>镜像（Image）：Docker 镜像（Image），就相当于是一个 root 文件系统。比如官方镜像 ubuntu:16.04 就包含了完整的一套 Ubuntu16.04 最小系统的 root 文件系统。</li><li>容器（Container）：镜像（Image）和容器（Container）的关系，就像是面向对象程序设计中的类和对象一样，镜像是静态的定义，容器是镜像运行时的实体。容器可以被创建、启动、停止、删除、暂停等。</li><li>仓库（Repository）：仓库可看成一个代码控制中心，用来保存镜像。</li></ul><h4 id="配置-docker-镜像加速器" tabindex="-1"><a class="header-anchor" href="#配置-docker-镜像加速器" aria-hidden="true">#</a> 配置 Docker 镜像加速器</h4><p>默认情况下，将来从docker hub（https://hub.docker.com/）上下载docker镜像，太慢。一般都会配置镜像加速器：</p><ul><li>USTC：中科大镜像加速器（https://docker.mirrors.ustc.edu.cn）</li><li>阿里云</li><li>网易云</li><li>腾讯云</li></ul><p>阿里云镜像加速器配置</p><p>首先登陆阿里云，点击控制台，然后再点击左边的像三字一样的图标，再点击产品与服务，在输入关键字地方搜索“镜像”，会显示容器镜像服务，点击“容器镜像服务”，在左侧的最下方有镜像中心（镜像加速器），点击镜像加速器，复制如下代码到linux执行即可</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>// 修改 /etc/docker/daemon.json 文件内容 提高下载速度
<span class="token function">sudo</span> <span class="token function">mkdir</span> <span class="token parameter variable">-p</span> /etc/docker

<span class="token function">sudo</span> <span class="token function">tee</span> /etc/docker/daemon.json <span class="token operator">&lt;&lt;-</span><span class="token string">&#39;EOF&#39;
{
  &quot;registry-mirrors&quot;: [&quot;https://88y9upwp.mirror.aliyuncs.com&quot;]
}
EOF</span>

<span class="token function">sudo</span> systemctl daemon-reload

<span class="token function">sudo</span> systemctl restart <span class="token function">docker</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="docker-网络模式" tabindex="-1"><a class="header-anchor" href="#docker-网络模式" aria-hidden="true">#</a> Docker 网络模式</h2><blockquote><p>在创建容器时可设置其网络模式: docker run -id -p 3307 :3306 --name=c_ mysql -e --net=host MYSQL_ ROOT_ PASSWORD=root mysql:5.6</p></blockquote><p>四类网络模式: https://segmentfault.com/a/1190000040335988</p><h3 id="bridge-模式-桥接" tabindex="-1"><a class="header-anchor" href="#bridge-模式-桥接" aria-hidden="true">#</a> bridge 模式 - 桥接</h3><blockquote><p>当Docker进程启动时，会在主机上创建一个名为docker0的虚拟网桥，此主机上启动的Docker容器会连接到这个虚拟网桥上。虚拟网桥的工作方式和物理交换机类似，这样主机上的所有容器就通过交换机连在了一个二层网络中。</p></blockquote><p>从docker0子网中分配一个IP给容器使用，并设置docker0的IP地址为容器的默认网关。在主机上创建一对虚拟网卡veth pair设备，Docker将veth pair设备的一端放在新创建的容器中，并命名为eth0（容器的网卡），另一端放在主机中，以vethxxx这样类似的名字命名，并将这个网络设备加入到docker0网桥中。可以通过brctl show命令查看。</p><p>bridge模式是docker的默认网络模式，不写--net参数，就是bridge模式。使用docker run -p时，docker实际是在iptables做了DNAT规则，实现端口转发功能。可以使用iptables -t nat -vnL查看。</p><h3 id="host-模式-仅主机模式" tabindex="-1"><a class="header-anchor" href="#host-模式-仅主机模式" aria-hidden="true">#</a> host 模式 - 仅主机模式</h3><p>如果启动容器的时候使用host模式，那么这个容器将不会获得一个独立的Network Namespace，而是和宿主机共用一个Network Namespace。容器将不会虚拟出自己的网卡，配置自己的IP等，而是使用宿主机的IP和端口。但是，容器的其他方面，如文件系统、进程列表等还是和宿主机隔离的</p><blockquote><p>使用host模式的容器可以直接使用宿主机的IP地址与外界通信，容器内部的服务端口也可以使用宿主机的端口，不需要进行NAT，host最大的优势就是网络性能比较好，但是docker host上已经使用的端口就不能再用了，网络的隔离性不好。</p></blockquote><h3 id="container-模式" tabindex="-1"><a class="header-anchor" href="#container-模式" aria-hidden="true">#</a> container 模式</h3><p>这个模式指定新创建的容器和已经存在的一个容器共享一个 Network Namespace，而不是和宿主机共享。新创建的容器不会创建自己的网卡，配置自己的 IP，而是和一个指定的容器共享 IP、端口范围等。同样，两个容器除了网络方面，其他的如文件系统、进程列表等还是隔离的。两个容器的进程可以通过 lo 网卡设备通信。</p><h4 id="none模式" tabindex="-1"><a class="header-anchor" href="#none模式" aria-hidden="true">#</a> none模式</h4><p>使用none模式，Docker容器拥有自己的Network Namespace，但是，并不为Docker容器进行任何网络配置。也就是说，这个Docker容器没有网卡、IP、路由等信息。需要我们自己为Docker容器添加网卡、配置IP等。</p><p>这种网络模式下容器只有lo回环网络，没有其他网卡。none模式可以在容器创建时通过--network=none来指定。这种类型的网络没有办法联网，封闭的网络能很好的保证容器的安全性。</p><h2 id="docker-命令" tabindex="-1"><a class="header-anchor" href="#docker-命令" aria-hidden="true">#</a> Docker 命令</h2><h3 id="进程相关命令" tabindex="-1"><a class="header-anchor" href="#进程相关命令" aria-hidden="true">#</a> 进程相关命令</h3><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>systemctl start <span class="token function">docker</span>    <span class="token comment">#启动docker服务</span>
systemctl stop <span class="token function">docker</span>     <span class="token comment">#停止docker服务 </span>
systemctl restart <span class="token function">docker</span>  <span class="token comment">#重启docker服务 </span>
systemctl status <span class="token function">docker</span>   <span class="token comment">#查看docker服务状态</span>
systemctl <span class="token builtin class-name">enable</span> <span class="token function">docker</span>   <span class="token comment">#开机启动docker服务</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="镜像相关命令" tabindex="-1"><a class="header-anchor" href="#镜像相关命令" aria-hidden="true">#</a> 镜像相关命令</h3><p>1、查看镜像: 查看本地所有的镜像</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker images      </span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker images –q ## 查看所有镜像的id</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>2、搜索镜像:从网络中查找需要的镜像</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token function">docker</span> imagesxxxxxxxxxx <span class="token function">docker</span> imagesdocker search 镜像名称<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker search  redisshell</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>3、拉取镜像:从Docker仓库下载镜像到本地，镜像名称格式为 名称:版本号，如果版本号不指定则是最新的版本，如果不知道镜像版本，可以去docker hub 搜索对应镜像查看。 https://hub.docker.com/_/docker</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token function">docker</span> pull 镜像名称:版本号
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker pull redis:5.0 </span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker pull centos:7 </span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">## docker pull mysql:5.6  |  docker pull mysql:8.0.25 </span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker pull tomcat:8 弃用</span>
				   <span class="token function">docker</span> pull openjdk:8
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker pull nginx</span>

<span class="token function">docker</span> pull java:8
<span class="token comment">## minio 文件对象存储 类似阿里云oss</span>
<span class="token function">docker</span> pull minio/minio 
<span class="token comment">## 安装消息队列</span>
<span class="token function">docker</span> pull rabbitmq:management
<span class="token comment">## 拉取 wordpress 主题网站镜像</span>
<span class="token function">docker</span> pull wordpress 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>4、删除镜像: 删除本地镜像</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>// 可根据 <span class="token function">docker</span> images 查询镜像id镜像删除
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker rmi 镜像id</span>
// 删除所有镜像
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker rmi `docker images -q`</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="容器相关命令" tabindex="-1"><a class="header-anchor" href="#容器相关命令" aria-hidden="true">#</a> 容器相关命令</h3><p>1、查看容器</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker ps       ## 查看正在运行的容器</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker ps -a    ## 查看所有容器 （包括没有运行的容器）</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>2、创建并启动容器</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>docker run <span class="token operator">-</span>it <span class="token punctuation">|</span> <span class="token operator">-</span>id <span class="token operator">--</span>name=容器名称 镜像名称:版本 <span class="token operator">/</span>bin/bash
<span class="token comment">#创建并自动进入容器,当输入exit 退出容器并回到宿主机</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker run -it --name=c1 centos:7 /bin/bash  </span>

<span class="token comment">#创建容器 但不进入容器 后台运行 可使用命令进入 且退出不会关闭容器</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker run -id --name=c2 centos:7		</span>

docker run <span class="token operator">-</span>id <span class="token operator">--</span>name=java_apai <span class="token operator">-</span>p 2022:2022 <span class="token operator">-</span>p 2023:2023 <span class="token operator">-</span>p 2024:2024 java:8
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>参数说明：</p><p>-i：保持容器运行。通常与 -t 同时使用。加入it这两个参数后，容器创建后自动进入容器中，退出容器后（执行命令exit），容器自动关闭</p><p>-t：为容器重新分配一个伪输入终端，通常与 -i 同时使用</p><p>-d：以守护（后台）模式运行容器。创建一个容器在后台运行，需要使用docker exec 进入容器。退出后，容器不会关闭</p><p>/bin/bash 这是表示载入容器后运行bash ,docker中必须要保持一个进程的运行，要不然整个容器就会退出。这个就表示启动容器后启动bash。默认会启动一个bash，可以忽略不写</p></blockquote><p>3、进入容器</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>docker exec 参数  <span class="token operator">/</span>bin<span class="token operator">/</span>bash      #进入容器  注意 此处的<span class="token operator">/</span>bin<span class="token operator">/</span>bash不能省略
<span class="token comment">// 启动容器  后台启动</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> <span class="token operator">~</span><span class="token punctuation">]</span>#docker <span class="token operator">-</span>id <span class="token operator">--</span>name<span class="token operator">=</span>c2 centos<span class="token operator">:</span><span class="token number">7</span>
<span class="token comment">// 进入容器  docker exec -it 容器名称 /bin/bash</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> <span class="token operator">~</span><span class="token punctuation">]</span>#docker exec <span class="token operator">-</span>it c2 <span class="token operator">/</span>bin<span class="token operator">/</span>bash
<span class="token comment">// 退出容器 此时容器还是在运行着的</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> <span class="token operator">~</span><span class="token punctuation">]</span>#exit        
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>4、启动容器</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>docker <span class="token function">start</span> 容器名称
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker start c1</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>5、停止容器运行</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>docker stop 容器名
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>6、删除容器</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>docker <span class="token function">rm</span> 容器名称       <span class="token comment">#如果容器是运行状态则删除失败，需要停止容器才能删除</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker rm c1</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>7、查看容器信息</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>docker inspect 容器名称
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker inspect  c1</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>8、查看docker日志</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code>docker logs <span class="token operator">--</span>tail 行数 <span class="token operator">-</span>f  容器名   
<span class="token comment">// 查看某个容器末尾300行的日志内容</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> <span class="token operator">~</span><span class="token punctuation">]</span>#docker logs <span class="token operator">--</span>tail  <span class="token number">300</span> <span class="token operator">-</span>f app<span class="token operator">-</span>jar  
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>9、docker容器安装命令</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>apt-get  update
apt-get  <span class="token operator">-</span>y install net-tools  <span class="token punctuation">|</span> yum <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>10、用于容器与主机之间的数据拷贝</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 将主机/root/123.war文件拷贝到容器96f7f14e99ab的/root目录下</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> <span class="token operator">~</span><span class="token punctuation">]</span>#docker cp <span class="token operator">/</span>root<span class="token operator">/</span><span class="token number">123.</span>war <span class="token number">96f</span><span class="token number">7f</span><span class="token number">14e99</span>ab<span class="token operator">:</span><span class="token operator">/</span>root<span class="token operator">/</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> <span class="token operator">~</span><span class="token punctuation">]</span>#docker cp <span class="token operator">/</span><span class="token class-name">Apai</span><span class="token operator">/</span><span class="token class-name">Login</span><span class="token punctuation">.</span>jar <span class="token number">5920698f</span><span class="token number">5</span>ad7<span class="token operator">:</span><span class="token operator">/</span>root<span class="token operator">/</span>

<span class="token comment">// 将容器96f7f14e99ab的/www目录拷贝到主机的/tmp目录中</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> <span class="token operator">~</span><span class="token punctuation">]</span>#docker cp  <span class="token number">5920698f</span><span class="token number">5</span>ad7<span class="token operator">:</span><span class="token operator">/</span>root <span class="token operator">/</span>tmp<span class="token operator">/</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h4 id="配置数据卷" tabindex="-1"><a class="header-anchor" href="#配置数据卷" aria-hidden="true">#</a> 配置数据卷</h4><p>语法：docker run ... –v 宿主机目录(文件):容器内目录(文件) ...</p><p>案例1：</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span>docker run <span class="token operator">-</span>it <span class="token operator">--</span>name=c3 <span class="token operator">-</span>v <span class="token operator">/</span>root/<span class="token keyword">data</span>:<span class="token operator">/</span>root/data_container centos:7 <span class="token operator">/</span>bin/bash
<span class="token namespace">[root@localhost ~]</span>docker run <span class="token operator">-</span>it <span class="token operator">--</span>name=c4 <span class="token operator">-</span>v <span class="token operator">/</span>root/<span class="token keyword">data</span>:<span class="token operator">/</span>root/contai1 <span class="token operator">-</span>v <span class="token operator">/</span>root/data1:<span class="token operator">/</span>root/contai2 centos:7
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>注意事项：</p><p>1、目录必须是绝对路径 （宿主机和容器目录都是绝对路径） 2、如果目录不存在，会自动创建 3、可以挂载多个数据卷</p><p>配置数据卷后，在/root/data下创建文件，发现会同步到c3容器的data_container目录中，同理反过来也一样，当删除容器后，此时并不影响宿主机/root/data里的内容</p></blockquote><p>案例2：多容器进行数据交换</p><p>步骤：</p><p>1、创建启动c3数据卷容器，使用 –v 参数 设置数据卷</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker run –it --name=c3 –v /volume centos:7 /bin/bash </span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker inspect c3      #查看c3容器</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>-v 后面的/volume是容器的目录，那么这个宿主机的目录为什么不见了呢?其实这个时候linux会自动创建一个目录（目录名很长）作为源目录和/volume容器目录相对应。可以通过 docker inspect c3 查看c3容器</p></blockquote><p>2、创建启动 c1 c2 容器，使用 –-volumes-from 参数 设置数据卷</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker run –it --name=c1 --volumes-from c3 centos:7 /bin/bash</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker run –it --name=c2 --volumes-from c3 centos:7 /bin/bash  </span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>此时c1和c2 挂载到和c3相同的宿主机的目录，在c3容器创建内容，c1和c2都会自动同步 (也就是说在c1和c2的根目录下也有 volume文件夹) [root@localhost ~]#docker inspect c1 [root@localhost ~]#docker inspect c2 发现c1 c2的宿主机目录和c3相同</p></blockquote><h4 id="数据卷小结" tabindex="-1"><a class="header-anchor" href="#数据卷小结" aria-hidden="true">#</a> 数据卷小结</h4><p>1、数据卷概念：宿主机的一个目录或文件 2、数据卷作用：容器数据持久化、客户端和容器数据交换、容器间数据交换 3、数据卷容器：创建一个容器，挂载一个目录，让其他容器继承自该容器( --volume-from )。通过简单方式实现数据卷配置</p><h2 id="docker-镜像制作" tabindex="-1"><a class="header-anchor" href="#docker-镜像制作" aria-hidden="true">#</a> Docker 镜像制作</h2><h3 id="docker-镜像原理" tabindex="-1"><a class="header-anchor" href="#docker-镜像原理" aria-hidden="true">#</a> Docker 镜像原理</h3><blockquote><p>本质是一个分层文件系统,由一层一层的文件系统叠加而成，最底端是 bootfs，并使用宿主机的bootfs ，第二层是 root文件系统rootfs，称为base image，然后再往上可以叠加其他的镜像文件，这种层级的文件系统被称之为UnionFS，统一文件系统（Union File System）技术能够将不同的层整合成一个文件系统，为这些层提供了一个统一的视角，这样就隐藏了多层的存在，在用户的角度看来，只存在一个文件系统</p><p>一个镜像可以放在另一个镜像的上面。位于下面的镜像称为父镜像，最底部的镜像成为基础镜像，当从一个镜像启动容器时，Docker会在最顶层加载一个读写文件系统作为容器</p></blockquote><h3 id="普通方式" tabindex="-1"><a class="header-anchor" href="#普通方式" aria-hidden="true">#</a> 普通方式</h3><blockquote><p>有些容器镜像 会排除某些文件 如: Mysql ... (具体见)</p></blockquote><p>制作tomcat镜像</p><p>1、首先创建一个tomcat容器</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost tomcat]</span><span class="token comment">## docker run -id --name=tomcat1 -p 8080:8080 tomcat:8</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>2、把宿主机的某个war包拷贝到容器的某个目录里面，这样将来做镜像时，war包会加载到镜像里</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost tomcat]</span><span class="token comment">## docker cp /root/test.war  #6598a89db5f6:/root   </span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><blockquote><p>注意：不能将内容拷贝到tomcat容器的webapp目录和var目录里，如果放到里面，做成镜像时，该目录下的内容不会载入镜像里面</p></blockquote><p>3、把tomcat容器做成镜像</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost tomcat]</span><span class="token comment">## docker commit 6598a89db5f6 woniu_tomcat:1.0</span>
<span class="token namespace">[root@localhost tomcat]</span><span class="token comment">## docker images   #可以查看到woniu_tomcat:1.0镜像</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>4、把镜像做成压缩包 放到宿主机的某个位置</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">## docker save -o woniu_tomcat.tar woniu_tomcat:1.0     #-o:output 压缩文件保存到/root目录下</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>5、把压缩文件载入镜像（第三方载入该压缩包）</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">## docker load -i woniu_tomcat.tar  #镜像加载 -i  （input）</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment">## docker images</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>6、用woniu_tomcat:1.0镜像做容器</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">## docker run -id --name=tomcat2 -p:8081:8080 woniu_tomcat:1.0</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment">## docker exec -it tomcat2 bash  #进入容器，进入/root 可以看到test.war存在</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="dockerfile方式" tabindex="-1"><a class="header-anchor" href="#dockerfile方式" aria-hidden="true">#</a> dockerfile方式</h3><blockquote><p>制作docker镜像的一个文本文件,文件包含了一条条的指令，每一条指令构建一层，基于基础镜像，最终构建出一个新的镜像，</p></blockquote><p>Dochub网址：https://hub.docker.com</p><p><strong>Dockerfile关键字</strong></p><table><thead><tr><th>关键字</th><th>作用</th><th>备注</th></tr></thead><tbody><tr><td>FROM</td><td>指定父镜像</td><td>指定dockerfile基于那个image构建</td></tr><tr><td>MAINTAINER</td><td>作者信息</td><td>用来标明这个dockerfile谁写的</td></tr><tr><td>LABEL</td><td>标签</td><td>用来标明dockerfile的标签 可以使用Label代替Maintainer 最终都是在docker image基本信息中可以查看</td></tr><tr><td>RUN</td><td>执行命令</td><td>执行一段命令 默认是/bin/sh 格式: RUN command 或者 RUN [&quot;command&quot; , &quot;param1&quot;,&quot;param2&quot;]</td></tr><tr><td>CMD</td><td>容器启动命令</td><td>提供启动容器时候的默认命令 和ENTRYPOINT配合使用.格式 CMD command param1 param2 或者 CMD [&quot;command&quot; , &quot;param1&quot;,&quot;param2&quot;]</td></tr><tr><td>ENTRYPOINT</td><td>入口</td><td>一般在制作一些执行就关闭的容器中会使用</td></tr><tr><td>COPY</td><td>复制文件</td><td>build的时候复制文件到image中</td></tr><tr><td>ADD</td><td>添加文件</td><td>build的时候添加文件到image中 不仅仅局限于当前build上下文 可以来源于远程服务, ADD 源路径 目标路径</td></tr><tr><td>ENV</td><td>环境变量</td><td>指定build时候的环境变量 可以在启动的容器的时候 通过-e覆盖 格式ENV name=value</td></tr><tr><td>ARG</td><td>构建参数</td><td>构建参数 只在构建的时候使用的参数 如果有ENV 那么ENV的相同名字的值始终覆盖arg的参数</td></tr><tr><td>VOLUME</td><td>定义外部可以挂载的数据卷</td><td>指定build的image那些目录可以启动的时候挂载到文件系统中 启动容器的时候使用 -v 绑定 格式 VOLUME [&quot;目录&quot;]</td></tr><tr><td>EXPOSE</td><td>暴露端口</td><td>定义容器运行的时候监听的端口 启动容器的使用-p来绑定暴露端口 格式: EXPOSE 8080 或者 EXPOSE 8080/udp</td></tr><tr><td>WORKDIR</td><td>工作目录</td><td>指定容器内部的工作目录 如果没有创建则自动创建 如果指定/ 使用的是绝对地址 如果不是/开头那么是在上一条workdir的路径的相对路径</td></tr><tr><td>USER</td><td>指定执行用户</td><td>指定build或者启动的时候 用户 在RUN CMD ENTRYPONT执行的时候的用户</td></tr><tr><td>HEALTHCHECK</td><td>健康检查</td><td>指定监测当前容器的健康监测的命令 基本上没用 因为很多时候 应用本身有健康监测机制</td></tr><tr><td>ONBUILD</td><td>触发器</td><td>当存在ONBUILD关键字的镜像作为基础镜像的时候 当执行FROM完成之后 会执行 ONBUILD的命令 但是不影响当前镜像 用处也不怎么大</td></tr><tr><td>STOPSIGNAL</td><td>发送信号量到宿主机</td><td>该STOPSIGNAL指令设置将发送到容器的系统调用信号以退出。</td></tr><tr><td>SHELL</td><td>指定执行脚本的shell</td><td>指定RUN CMD ENTRYPOINT 执行命令的时候 使用的shell</td></tr></tbody></table><p>案例2：定义dockerfile文件构建镜像，发布springboot项目</p><p>步骤1：创建dockerfile文件并编写内容</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost docker-file]</span><span class="token comment">#vim springboot-dockerfile</span>
编写内容如下：
<span class="token keyword">FROM</span> java:8
MAINTAINER  woniu&lt;woniu@woniu<span class="token punctuation">.</span>cn&gt;
ADD springboot<span class="token punctuation">.</span>jar app<span class="token punctuation">.</span>jar   
CMD java <span class="token operator">-</span>jar <span class="token operator">/</span>app<span class="token punctuation">.</span>jar
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>说明：</p><p>ADD springboot.jar app.jar 表示把宿主机的springboot.jar复制到镜像里并更名为app.jar,当用镜像做容器时，app.jar默认在容器的根目录</p></blockquote><p>步骤2：通过dockerfile构建镜像</p><p>特别注意: 最后有一个点 &#39; . &#39;</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost docker-file]</span><span class="token comment">## docker build -f  ./springboot-dockerfile -t  springboot-app:1.0 .</span>
<span class="token namespace">[root@localhost docker-file]</span><span class="token comment">## docker images</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>步骤3：通过springboot-app:1.0镜像创建容器</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost docker-file]</span><span class="token comment">## docker run -it --name=app -p 8080:8080 springboot-app:1.0</span>
<span class="token namespace">[root@localhost docker-file]</span><span class="token comment">#docker logs --tail 100 -f  app    #查看app容器的日志  末尾100行</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="compose-服务编排" tabindex="-1"><a class="header-anchor" href="#compose-服务编排" aria-hidden="true">#</a> Compose 服务编排</h2><blockquote><p>Docker Compose是“容器编排技术”。它由Python 语言编写，是Docker官方的一个开源项目，简单来讲，就是编排好一个系统中的众多容器的启动顺序，先启动A，再启动B，在启动C。</p></blockquote><h3 id="安装-compose" tabindex="-1"><a class="header-anchor" href="#安装-compose" aria-hidden="true">#</a> 安装 Compose</h3><p>Compose目前已经完全支持Linux、Mac OS和Windows，在我们安装Compose之前，需要先安装Docker。下面我 们以编译好的二进制包方式安装在Linux系统中。</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose</span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#chmod +x /usr/local/bin/docker-compose    ## 设置文件可执行权限</span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker-compose -version					 ## 查看版本信息 </span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="卸载-compose" tabindex="-1"><a class="header-anchor" href="#卸载-compose" aria-hidden="true">#</a> 卸载 Compose</h3><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">#rm /usr/local/bin/docker-compose   ## 二进制包方式安装的，删除二进制文件即可</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="comnpose的使用步骤" tabindex="-1"><a class="header-anchor" href="#comnpose的使用步骤" aria-hidden="true">#</a> Comnpose的使用步骤</h3><p>1、利用 Dockerfile 定义运行环境镜像 2、使用 docker-compose.yml 文件定义组成应用的各服务的运行顺序 3、运行 docker-compose up 启动应用</p><p>案例: 具体详见 Docker 详情.md</p><h2 id="分隔" tabindex="-1"><a class="header-anchor" href="#分隔" aria-hidden="true">#</a> ------------ 分隔 ------------</h2><h2 id="linux-常用命令" tabindex="-1"><a class="header-anchor" href="#linux-常用命令" aria-hidden="true">#</a> Linux 常用命令</h2><h3 id="文件类-功能类-命令" tabindex="-1"><a class="header-anchor" href="#文件类-功能类-命令" aria-hidden="true">#</a> 文件类 功能类 命令</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// tar 解压缩 命令</span>
tar <span class="token operator">-</span>zxvf 压缩名 <span class="token operator">-</span><span class="token class-name">C</span> 目录名
<span class="token comment">// 查看进程 端口信息</span>
netstat <span class="token operator">-</span>tlnp
<span class="token comment">// 根据端口 关闭进程</span>
kill <span class="token operator">-</span><span class="token number">9</span> 端口号
<span class="token comment">// 关闭防火墙</span>
systemctl stop firewalld<span class="token punctuation">.</span>service
<span class="token comment">// 将文件变为可执行文件</span>
chmod <span class="token operator">+</span>x 文件
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="redis-命令" tabindex="-1"><a class="header-anchor" href="#redis-命令" aria-hidden="true">#</a> redis 命令</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 启动redis服务器</span>
cd <span class="token operator">/</span>usr<span class="token operator">/</span>local<span class="token operator">/</span>bin  <span class="token comment">// 进入bin目录执行</span>
<span class="token punctuation">.</span>/redis<span class="token operator">-</span>server redis<span class="token punctuation">.</span>conf
<span class="token comment">// 启动redis客户端</span>
redis<span class="token operator">-</span>cli <span class="token operator">-</span>h <span class="token number">192.168</span><span class="token number">.174</span><span class="token number">.128</span> <span class="token operator">-</span>p <span class="token number">6379</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="nginx-命令" tabindex="-1"><a class="header-anchor" href="#nginx-命令" aria-hidden="true">#</a> nginx 命令</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 进入sbin目录 启动nginx</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> sbin<span class="token punctuation">]</span>## <span class="token punctuation">.</span>/nginx 
<span class="token comment">// 关闭nginx：</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> sbin<span class="token punctuation">]</span>## <span class="token punctuation">.</span>/nginx <span class="token operator">-</span>s stop
<span class="token comment">// 推荐使用：</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> sbin<span class="token punctuation">]</span>## <span class="token punctuation">.</span>/nginx <span class="token operator">-</span>s quit
<span class="token comment">// 重启nginx： 1、先关闭后启动。 2、刷新配置文件：</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> sbin<span class="token punctuation">]</span>## <span class="token punctuation">.</span>/nginx <span class="token operator">-</span>s reload
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="运行jar包-命令" tabindex="-1"><a class="header-anchor" href="#运行jar包-命令" aria-hidden="true">#</a> 运行jar包 命令</h3><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 特点：当前ssh窗口被锁定，可按CTRL + C打断程序运行，或直接关闭窗口，程序退出</span>
java <span class="token operator">-</span>jar <span class="token constant">XXX</span><span class="token punctuation">.</span>jar
<span class="token comment">// 特定：当前ssh窗口不被锁定，但是当窗口关闭时，程序中止运行。 &amp;代表在后台运行</span>
java <span class="token operator">-</span>jar xxx<span class="token punctuation">.</span>jar <span class="token operator">&amp;</span>
<span class="token comment">// nohup 意思是不挂断运行命令,当账户退出或终端关闭时,程序仍然运行</span>
nohup java <span class="token operator">-</span>jar shareniu<span class="token punctuation">.</span>jar <span class="token operator">&amp;</span>    
<span class="token comment">// nohup 命令执行作业时，缺省情况下的所有输出被重定向到nohup.out的文件中，除非另外指定了输出文件。</span>
<span class="token comment">// 将command的输出重定向到out.file文件，即输出内容不打印到屏幕上，而是输出到out.file文件中。</span>
nohup java <span class="token operator">-</span>jar shareniu<span class="token punctuation">.</span>jar <span class="token operator">&gt;</span>out<span class="token punctuation">.</span>file <span class="token operator">&amp;</span>
<span class="token comment">// 指定端口</span>
java <span class="token operator">-</span>jar <span class="token constant">XXX</span><span class="token punctuation">.</span>jar <span class="token operator">--</span>server<span class="token punctuation">.</span>port<span class="token operator">=</span><span class="token number">8081</span> <span class="token operator">&gt;</span> demo<span class="token punctuation">.</span>out <span class="token operator">&amp;</span>
nohup java <span class="token operator">-</span>jar <span class="token constant">XXX</span><span class="token punctuation">.</span>jar <span class="token operator">--</span>server<span class="token punctuation">.</span>port<span class="token operator">=</span><span class="token number">8081</span> <span class="token operator">&gt;</span> demo<span class="token punctuation">.</span>out <span class="token operator">&amp;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="docker-命令-1" tabindex="-1"><a class="header-anchor" href="#docker-命令-1" aria-hidden="true">#</a> Docker 命令</h3><blockquote><p>Docker</p></blockquote><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 进程相关命令</span>
systemctl start docker    #启动docker服务
systemctl stop docker     #停止docker服务 
systemctl restart docker  #重启docker服务 
systemctl status docker   #查看docker服务状态
systemctl enable docker   #开机启动docker服务
<span class="token comment">// 查看镜像: 查看本地所有的镜像</span>
docker images  
<span class="token comment">// 拉取镜像</span>
docker pull 镜像名称<span class="token operator">:</span>版本号 
<span class="token comment">// 删除镜像</span>
docker rmi 镜像id
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>容器相关命令</p></blockquote><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token operator">--</span>restart<span class="token operator">=</span>always <span class="token operator">-&gt;</span> 表示docker容器开机自启

<span class="token comment">// 查看容器</span>
docker ps       ## 查看正在运行的容器
docker ps <span class="token operator">-</span>a    ## 查看所有容器 （包括没有运行的容器）
<span class="token comment">// 创建容器 但不进入容器 后台运行 可使用命令进入 且退出不会关闭容器  </span>
<span class="token comment">// --restart=always -&gt; 表示docker容器开机自启</span>
docker run <span class="token operator">-</span>id <span class="token operator">--</span>name<span class="token operator">=</span>容器名称 镜像名称<span class="token operator">:</span>版本
<span class="token comment">// 进入容器</span>
docker exec <span class="token operator">-</span>it 容器id <span class="token operator">/</span>bin<span class="token operator">/</span>bash
<span class="token comment">// 启动容器 </span>
docker start 容器名称
<span class="token comment">// 停止容器运行</span>
docker stop 容器名
<span class="token comment">// 删除容器 运行状态则删除失败，需要停止容器才能删除</span>
docker rm 容器名称
    
<span class="token comment">// 将主机/root/123.war文件拷贝到容器96f7f14e99ab的/root目录下</span>
docker cp <span class="token operator">/</span>root<span class="token operator">/</span><span class="token number">123.</span>war <span class="token number">96f</span><span class="token number">7f</span><span class="token number">14e99</span>ab<span class="token operator">:</span><span class="token operator">/</span>root<span class="token operator">/</span>
docker cp <span class="token operator">/</span><span class="token class-name">Apai_File</span><span class="token operator">/</span>app<span class="token operator">/</span>wxpuls<span class="token punctuation">.</span>jar c90863cd35eb<span class="token operator">:</span><span class="token operator">/</span>root<span class="token operator">/</span>

<span class="token comment">// 将容器96f7f14e99ab的/www目录拷贝到主机的/tmp目录中</span>
docker cp  <span class="token number">96f</span><span class="token number">7f</span><span class="token number">14e99</span>ab<span class="token operator">:</span><span class="token operator">/</span>root <span class="token operator">/</span>tmp<span class="token operator">/</span>
    
<span class="token comment">// 容器安装命令</span>
apt update  <span class="token comment">// 更新源</span>
apt<span class="token operator">-</span>get install vim  <span class="token comment">// 容器安装vim </span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="项目-部署" tabindex="-1"><a class="header-anchor" href="#项目-部署" aria-hidden="true">#</a> 项目 部署</h2><h3 id="war包部署" tabindex="-1"><a class="header-anchor" href="#war包部署" aria-hidden="true">#</a> war包部署</h3><blockquote><p>即 使用tomcat插件运行的项目</p></blockquote><p>1.先在IDEA 本地运行是否正常,</p><p>2.使用 package 打包 储存在 tager 目录下 .war</p><p>3.将 war 放入 tomcat 的 webapps 文件夹下</p><p>4.启动 tomcat 即可</p><p>5.在浏览器使用 ip地址:端口号/war包名 进行访问</p><ul><li>http://192.168.174.128:8080/chaoshi/</li></ul><p>注意:</p><blockquote><p>ieda 项目的过滤器为等于请求 在Linux系统里请求是带上了包名</p><p>则会被拦截导致无法登录 解决方法: 在过滤器 不是等于而是使用 uri.contains(&quot;/user/login&quot;) 包含</p><p>打包前使用的 tomcat 版本 需和Linux系统 的tomcat 版本一致</p><p>在访问时 必须带上war名 否则无法正常无法</p></blockquote><h3 id="jar包部署" tabindex="-1"><a class="header-anchor" href="#jar包部署" aria-hidden="true">#</a> jar包部署</h3><blockquote><p>即 使用启动类 的项目</p></blockquote><p>1.将项目的 jar 包放入 Linux 系统里的任意文件夹下</p><p>2.使用 后台运行jar包 的指令启动 nohup java -jar XXX.jar &amp;</p><p>3.在浏览器请求</p><h3 id="ngins-进行-项目部署" tabindex="-1"><a class="header-anchor" href="#ngins-进行-项目部署" aria-hidden="true">#</a> ngins 进行 项目部署</h3><blockquote><p>Nginx是一款高性能的http 服务器/反向代理服务器及电子邮件（IMAP/POP3）代理服务器。</p><p>详见: nginx.md</p><p>网址: Nginx配置——反向代理</p><p>(https://blog.csdn.net/zxd1435513775/article/details/102508463)</p></blockquote><p><strong>启动nginx</strong></p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 进入sbin目录</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> sbin<span class="token punctuation">]</span>## <span class="token punctuation">.</span>/nginx 
<span class="token comment">// 关闭nginx：</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> sbin<span class="token punctuation">]</span>## <span class="token punctuation">.</span>/nginx <span class="token operator">-</span>s stop
<span class="token comment">// 推荐使用：</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> sbin<span class="token punctuation">]</span>## <span class="token punctuation">.</span>/nginx <span class="token operator">-</span>s quit
<span class="token comment">// 重启nginx：</span>
<span class="token comment">// 1、先关闭后启动。 2、刷新配置文件：</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> sbin<span class="token punctuation">]</span>## <span class="token punctuation">.</span>/nginx <span class="token operator">-</span>s reload
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>nginx配置文件</strong></p><p>打开Nginx的配置文件：</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost nginx<span class="token punctuation">]</span><span class="token comment">## vim  conf/nginx.conf</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><ul><li><p>通过端口区分不同虚拟机</p><p>触发: 192.127.0.1:80</p></li></ul><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>server <span class="token punctuation">{</span>
	<span class="token comment">## 监听端口</span>
    listen       <span class="token number">80</span><span class="token punctuation">;</span>
    <span class="token comment">## 监听 ip</span>
    server_name  localhost<span class="token punctuation">;</span>
    <span class="token comment">## 监听到后执行</span>
    location / <span class="token punctuation">{</span>
    <span class="token comment">## 相对路径的文件夹</span>
    root   html<span class="token punctuation">;</span>
    <span class="token comment">## 文件夹内的index.html页面</span>
    index  index.html index.htm<span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

server <span class="token punctuation">{</span>
    listen  <span class="token number">81</span><span class="token punctuation">;</span>
    server_name  <span class="token number">192.168</span>.174.130<span class="token punctuation">;</span>
 
    location /api <span class="token punctuation">{</span>
        proxy_pass  http://192.168.174.130:8080<span class="token punctuation">;</span>
        rewrite <span class="token string">&quot;^/api/(.*)$&quot;</span> /<span class="token variable">$1</span> <span class="token builtin class-name">break</span><span class="token punctuation">;</span>  
    <span class="token punctuation">}</span> 
    location / <span class="token punctuation">{</span>
         root   pai-erp<span class="token punctuation">;</span>
         index  index.html index.htm<span class="token punctuation">;</span>
     <span class="token punctuation">}</span>
    error_page   <span class="token number">500</span> <span class="token number">502</span> <span class="token number">503</span> <span class="token number">504</span>  /50x.html<span class="token punctuation">;</span>
    location <span class="token operator">=</span> /50x.html <span class="token punctuation">{</span>
        root   html<span class="token punctuation">;</span>
    <span class="token punctuation">}</span> 
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>说明：一个server节点就是一个虚拟主机，html是nginx安装目录下的html目录(静态页面存放的位置,也可以使用绝对路径)，可以配置多个server，配置了多个虚拟主机</p></blockquote><ul><li>通过域名区分虚拟主机</li></ul><h5 id="nginx的配置-1" tabindex="-1"><a class="header-anchor" href="#nginx的配置-1" aria-hidden="true">#</a> Nginx的配置</h5><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>server <span class="token punctuation">{</span>
        listen       80<span class="token punctuation">;</span>
        server_name  www<span class="token punctuation">.</span>jd<span class="token punctuation">.</span>com<span class="token punctuation">;</span>
        location <span class="token operator">/</span> <span class="token punctuation">{</span>
            root   html-jd<span class="token punctuation">;</span>
            index  index<span class="token punctuation">.</span>html index<span class="token punctuation">.</span>htm<span class="token punctuation">;</span>
        <span class="token punctuation">}</span>
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h2 id="linux-安装" tabindex="-1"><a class="header-anchor" href="#linux-安装" aria-hidden="true">#</a> Linux 安装</h2><h3 id="nginx-安装" tabindex="-1"><a class="header-anchor" href="#nginx-安装" aria-hidden="true">#</a> nginx 安装</h3><ul><li><p>解压 tar -zxvf nginx-1.8.0.tar.gz 解压后可改名</p></li><li><p>源码包的根目录下没有这个Makefile，那么源码包就会有一个configure可执行文件，这个文件的作用就是用来做环境检查和环境配置的 执行以下命令</p></li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><ul><li>然后返现检查失败，需要一些依赖包</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><ul><li>然后再检查，通过了</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>make &amp;&amp;  make install 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><ul><li><p>编译</p><p>make 在源码包的根目录下执行make命令即可</p></li><li><p>安装</p><p>make install 在源码包的根目录下执行make install命令即可</p></li></ul><ul><li><h6 id="源码包的卸载" tabindex="-1"><a class="header-anchor" href="#源码包的卸载" aria-hidden="true">#</a> 源码包的卸载</h6><p>直接删除这个安装目录即可</p></li></ul><h3 id="源码包" tabindex="-1"><a class="header-anchor" href="#源码包" aria-hidden="true">#</a> 源码包</h3><blockquote><p>定义：就是程序员开发出来的包，没有编译的包。</p><p>优点：所以我们可以去改源码</p><p>缺点：所以安装的时候要先编译,然后再安装，这个过程要长些</p><p>源码包：一般来说，包里面会有一个src目录，该目录里面放源码</p></blockquote><p><strong>源码包的安装</strong></p><ul><li><p>检查当前的系统是否有必备的安装环境</p></li><li><p>解压 tar -zxvf 包名</p><blockquote><p>当我们要编译一个源码包的时候，一定要看看这个源码包里面是否有一个Makefile文件，因为编译的时候需要这个文件，这个文件的作用就是把一些安装配置写到这个文件的。</p></blockquote></li><li><p>如果有，则可以直接编译，当然在编译之前还要看看是否有c语言的编译器。</p><blockquote><p>如果有，则可以直接编译，当然在编译之前还要看看是否有c语言的编译器。如果没有编译器，则要先安装</p></blockquote><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>yum  -y   install   gcc-c++

注意：有可能第一次没装成功，那么就需要清一下缓存
make  distclean  清缓存
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div></li><li><p>如果没有编译器，则要先安装</p><blockquote><p>如果没有这个文件，那么就不能直接编译，必须要先生成这个文件，那么怎么生成？</p><p>如：安装nginx，发现源码包的根目录下没有这个Makefile，那么源码包就会有一个configure可执行文件，这个文件的作用就是用来做环境检查和环境配置的</p></blockquote><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>然后返现检查失败，需要一些依赖包</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>然后再检查，通过了</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>make &amp;&amp;  make install 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div></li><li><p>编译</p><p>make 在源码包的根目录下执行make命令即可</p></li><li><p>安装</p><p>make install 在源码包的根目录下执行make install命令即可</p></li></ul><ul><li><h6 id="源码包的卸载-1" tabindex="-1"><a class="header-anchor" href="#源码包的卸载-1" aria-hidden="true">#</a> 源码包的卸载</h6><p>直接删除这个安装目录即可</p></li></ul><h3 id="脚本包" tabindex="-1"><a class="header-anchor" href="#脚本包" aria-hidden="true">#</a> 脚本包</h3><blockquote><p>它其实是源码包中的一种，类似于window的软件安装。我们只需要找到这个脚本包的bin目录，去执行一个脚本文件。一般来说叫 startup.sh 例如：tomcat</p></blockquote><h3 id="rpm包-二进制包" tabindex="-1"><a class="header-anchor" href="#rpm包-二进制包" aria-hidden="true">#</a> rpm包（二进制包)</h3><blockquote><p>二进制包也叫rpm(redhat package manager), 包名一般来说以.rpm结尾</p></blockquote><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>httpd-2.4.6-88.el7.centos.x86_64.rpm 

包名：httpd
包版本：2.4.6
包发布了多少次：88
包的依赖环境  el7.centos.x86_64
包的后缀后：.rpm 

httpd-2.4.6-88.el7.centos.x86_64.rpm  整个包全名
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>rpm包安装起来是最复杂的，因为他的依赖太多。</p></blockquote><ul><li>检查一下当前系统是否已经装过这个软件包</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>rpm  -qa   查询当前已经安装了哪些rpm包
rpm  -qa  |  grep httpd
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><ul><li>卸载rpm包</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>rpm  -e  包名
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><ul><li>安装一个rpm包</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>rpm   -ivh   （install  verbose  hash ）   包全名
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><ul><li>包升级</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>rpm -Uvh  包全名
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="yum安装" tabindex="-1"><a class="header-anchor" href="#yum安装" aria-hidden="true">#</a> yum安装</h3><blockquote><p>当我们用yum去安装一个软件或者是一个命令，那么在我们的linux系统中有一个yum源文件，这个文件就是保存了yum的中央仓库地址，这个文件在/etc/yum.repos.d/目录下，你看到了很多文件，其中有一个yum中央仓库文件，叫CentOS-Base.repo，当然这里还有其他的文件，可以用来配置本地yum源</p></blockquote><ul><li>查询</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>yum   list  | grep  你的包名
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>注意：yum不存在包名和包全名的概念，统一叫包名</p><p>如：安装 httpd</p><ul><li>安装</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>yum -y  install  httpd  ###这个httpd就是包名

如：  yum -y install  vim
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>有些软件在这个yum源的中央仓库并没有这个包，那么要去下载专业的yum源。把这个专业的yum源安装了，再可以安装某个包</p><p>如：安装mysql</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>先检查有没有安装过mysql
rpm  -qa| grep mysql,如果安装过就卸载
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>我们安装专业的yum源</p><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>yum localinstall mysql-community-release-el5-5.noarch.rpm 
 
#这个mysql-community-release-el5-5.noarch.rpm 就是一个yum源
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><ul><li>升级</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>yum  -y update  包名
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><ul><li>卸载</li></ul><div class="language-text line-numbers-mode" data-ext="text"><pre class="language-text"><code>yum  -y remove 包名
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="工具-安装" tabindex="-1"><a class="header-anchor" href="#工具-安装" aria-hidden="true">#</a> 工具 安装</h3><h4 id="jdk-的安装" tabindex="-1"><a class="header-anchor" href="#jdk-的安装" aria-hidden="true">#</a> jdk 的安装</h4><p>1.将压缩包放入 root 文件夹内</p><ul><li>tar -zxvf 包名</li></ul><p>2.解压改名为 jdk8</p><ul><li>rm 原名 新名</li></ul><p>3.vim /etc/profile 修改配置文件</p><ul><li><p>末尾添加</p></li><li><p>export JAVA_HOME=/usr/local/btjdk/jdk8</p></li><li><p>export PATH=$JAVA_HOME/bin:$PATH</p></li></ul><p>4.source /etc/profile 刷新</p><p>5.验证是否安装成功 java javac 如出现一大串即成功</p><h4 id="tomcan8-的安装" tabindex="-1"><a class="header-anchor" href="#tomcan8-的安装" aria-hidden="true">#</a> tomcan8 的安装</h4><p>前提需安装 jdk</p><p>1.将压缩包放入 root 文件夹内</p><p>2.解压改名为 tomcan8</p><p>3.执行 /root/tomcat9/bin 目录下 ./startup.sh</p><p>4.查看端口 netstat -tlnp</p><p>5.关闭防火墙 systemctl stop firewalld.service</p><p>6.在浏览器 根据ip地址和端口进行连接</p><h4 id="mysql-版本5-6安装" tabindex="-1"><a class="header-anchor" href="#mysql-版本5-6安装" aria-hidden="true">#</a> Mysql 版本5.6安装</h4><blockquote><p>如遇出错: 备用 <a href="https://www.cnblogs.com/lenny-z/p/15666149.html" target="_blank" rel="noopener noreferrer">linux安装 mysql &gt;&gt;http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm - 御本美琴初号机 - 博客园 (cnblogs.com)<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></p></blockquote><blockquote><p>宝塔: <a href="https://blog.csdn.net/weixin_44893902/article/details/121242965" target="_blank" rel="noopener noreferrer">(9条消息) 如何使用Navicat连接宝塔面板上安装的mysql数据库？_明金同学的博客-CSDN博客_navicat连接宝塔mysql<span><svg class="external-link-icon" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path><polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg><span class="external-link-icon-sr-only">open in new window</span></span></a></p></blockquote><p>1.先检查有没有安装过mysql</p><ul><li>rpm -qa| grep mysql,如果安装过就卸载</li></ul><p>2.安装专业的yum源</p><ul><li><p>执行 yum localinstall mysql-community-release-el5-5.noarch.rpm</p></li><li><p>mysql-community-release-el5-5.noarch.rpm 就是一个yum源文件</p></li></ul><p>3.安装mysql的服务端</p><ul><li>yum install mysql-community-server</li></ul><p>4.开启mysql的服务</p><ul><li>service mysqld start</li></ul><p>5.然后设置密码</p><ul><li>/usr/bin/mysqladmin -u root password &#39;root&#39;</li></ul><p>6.登录</p><ul><li>mysql -uroot -p123456</li></ul><p>7.查看</p><ul><li>Mysql &gt; show databases; 查看表 注意: 分号 &#39; ; &#39;</li><li>Mysql &gt; exit 退出</li></ul><p>8.开启mysql远程访问权限</p><ul><li>Mysql &gt; grant all privileges on <em>.</em> to &#39;root&#39;@&#39;%&#39; identified by &#39;102528&#39; with grant option;</li><li>Mysql &gt; flush privileges; 刷新数据库配置</li><li>Mysql &gt; exit; 退出</li></ul><p>9.Navicat Premium 12 进行连接</p><p><img src="https://apaiimages.oss-cn-guangzhou.aliyuncs.com/MD/image-20220622203106853.png" alt="image-20220622203106853"></p><h2 id="docker-应用部署" tabindex="-1"><a class="header-anchor" href="#docker-应用部署" aria-hidden="true">#</a> Docker 应用部署</h2><h3 id="_1-mysql-部署" tabindex="-1"><a class="header-anchor" href="#_1-mysql-部署" aria-hidden="true">#</a> 1.mysql 部署</h3><p>1、搜索mysql镜像</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker search mysql</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>2、拉取mysql镜像</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker pull mysql:5.6</span>

<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker pull mysql:8.0.25</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>3、创建目录 在/root目录下创建mysql目录用于存储mysql数据信息</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">#mkdir mysql</span>
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#cd mysql</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p>4、创建容器，设置端口映射和目录映射</p><blockquote><p>此段为一句话 注意最后面为 版本号 未镜像则会先下载镜像</p><p>-p 3307:3306 --&gt; 3307 被 容器的数据库3306端口映射 外部可通过宿主机3307端口访问</p><p>-e MYSQL_ROOT_PASSWORD=root --&gt; 在创建容器进行写入配置</p><p>注意: mysql 8.0.25 连接外部需开启远程访问 对照下方解决方法</p></blockquote><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code>docker run <span class="token operator">-</span>id <span class="token operator">-</span>p 3307:3306 <span class="token operator">--</span>name=c_mysql <span class="token operator">--</span>restart=always <span class="token operator">-</span>v <span class="token operator">/</span>root/mysql/conf:<span class="token operator">/</span>etc/mysql/conf<span class="token punctuation">.</span>d <span class="token operator">-</span>v <span class="token operator">/</span>root/mysql/logs:<span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>log/mysql <span class="token operator">-</span>v <span class="token operator">/</span>root/mysql/<span class="token keyword">data</span>:<span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span><span class="token operator">/</span>lib/mysql <span class="token operator">-</span>e MYSQL_ROOT_PASSWORD=root mysql:8<span class="token punctuation">.</span>0<span class="token punctuation">.</span>25

docker run <span class="token operator">-</span>id <span class="token operator">-</span>p 3307:3306 <span class="token operator">--</span>name=Apai_mysql <span class="token operator">--</span>restart=always <span class="token operator">-</span>v <span class="token operator">/</span>Apai_File/mysql/conf:<span class="token operator">/</span>etc/mysql/conf<span class="token punctuation">.</span>d <span class="token operator">-</span>v <span class="token operator">/</span>Apai_File/mysql/logs:<span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>log/mysql <span class="token operator">-</span>v <span class="token operator">/</span>Apai_File/mysql/<span class="token keyword">data</span>:<span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>lib/mysql <span class="token operator">-</span>e MYSQL_ROOT_PASSWORD=root mysql:8<span class="token punctuation">.</span>0<span class="token punctuation">.</span>25

docker run <span class="token operator">-</span>id <span class="token operator">-</span>p 3307:3306 <span class="token operator">--</span>name=Apai_mysql <span class="token operator">--</span>restart=always <span class="token operator">-</span>e MYSQL_ROOT_PASSWORD=root mysql:8<span class="token punctuation">.</span>0<span class="token punctuation">.</span>25
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>1、 -p 3307:3306 将容器的 3306 端口映射到宿主机的 3307端口 2、-v /root/mysql/conf:/etc/mysql/conf.d 将宿主机当前mysql目录里面的 conf目录挂载到容器的 /etc/mysql/conf.d目录下，在mysql5的版本中，mysql容器启动默认加载 /etc/mysql/mysql.cnf配置文件，这个文件没有什么内容，只是文件的末尾有2句 !includedir /etc/mysql/conf.d/和!includedir /etc/mysql/mysql.conf.d/，表示这两个目录里面的文件都可以作为参数文件，mysql会读取这两个目录里面的.cnf结尾的文件，而/etc/mysql/conf.d/目录里面虽然有以.cnf 末尾结尾的文件，但是都没内容，所以我们把这个目录conf.d和宿主机的/root/mysql/conf做一个映射，那么在宿主机的该目录下放一些*.cnf文件会同步到/etc/mysql/conf.d就可以作为mysql的参数文件了，一旦做了映射，那么etc/mysql/conf.d目录就为空了。另外 /etc/mysql/mysql.conf.d/目录的下有mysql的参数文件 mysqld.cnf，这个文件配置了mysql启动时的进程id，datadir数据目录等</p><p>3、容器的mysql启动后，日志文件保存在/var/log/mysql目录里 4、容器的mysql启动后，数据库文件保存在/var/lib/mysql目录里 会同步到宿主机目录</p></blockquote><p>当然我们也可以不用挂载</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker run -id -p 3307:3306 --name=c_mysql -e MYSQL_ROOT_PASSWORD=root mysql:5.6</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p><strong>navicat连接; ip地址 端口为 3307</strong></p><p><strong>安装mysql8版本</strong></p><p>如果是8.0.25的数据库，navicat连接报错1251-Client does not support</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token operator">/</span><span class="token operator">/</span> 创建容器 未挂载
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker run -id -p 1001:3306  --name=c_mysql --restart=always -e MYSQL_ROOT_PASSWORD=root mysql:8.0.25</span>
<span class="token operator">/</span><span class="token operator">/</span> 进入容器
<span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker exec -it Apai_mysql /bin/bash</span>
<span class="token operator">/</span><span class="token operator">/</span> 在容器内 登录数据库
root@053f48be0dc7:~<span class="token comment">## mysql -uroot -proot</span>
<span class="token operator">/</span><span class="token operator">/</span> 设置远程客户端（如navicat）连接的密码，不是mysql服务器的登录密码
mysql&gt; ALTER USER <span class="token string">&#39;root&#39;</span>@<span class="token string">&#39;%&#39;</span> IDENTIFIED WITH mysql_native_password BY <span class="token string">&#39;lj102528@&#39;</span><span class="token punctuation">;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>使用外部机器连接容器中的mysql</p><blockquote><p>记一次mysql启动报错。查看日志报错为：</p><p>Can&#39;t open and lock privilege tables: Table storage engine for &#39;user&#39;</p><p>方案：将datadir路径下的文件清空，然后执行如下命令：</p><p>mysqld --initialize --user=mysql --basedir=/usr --datadir=/var/lib/mysql</p><p>然后重启：service mysql start</p></blockquote><h3 id="_2-tomcat-部署" tabindex="-1"><a class="header-anchor" href="#_2-tomcat-部署" aria-hidden="true">#</a> 2.Tomcat 部署</h3><p>1、搜索tomcat镜像</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker search tomcat</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>2、拉取tomcat镜像</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker pull tomcat:8</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>3、创建容器，设置端口映射、目录映射</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token comment">## 在/root目录下创建tomcat目录用于存储tomcat数据信息</span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">## mkdir tomcat</span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">## cd tomcat</span>
<span class="token punctuation">[</span>root@localhost tomcat<span class="token punctuation">]</span><span class="token comment">#docker run -id --name=c_tomcat -p 8080:8080 -v $PWD:/usr/local/tomcat/webapps tomcat:8</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>参数说明：</p><p>-p 8080:8080：将容器的8080端口映射到主机的8080端口 （第一个8080是宿主机端口用来和tomcat做映射的，第二个8080是容器启动tomcat端口8080，第二个端口是tomcat容器默认启动的端口） -v $PWD:/usr/local/tomcat/webapps：将主机中当前目录挂载到容器的webapps</p></blockquote><p>4、使用外部机器访问tomcat</p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// 在宿主机目录/root/tomcat下创建test目录。并在test目录下创建index.html。那么test目录会同步到c_tomcat容器的 /usr/local/tomcat/webapps里面</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> tomcat<span class="token punctuation">]</span>## mkdir test
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> tomcat<span class="token punctuation">]</span>## cd test<span class="token operator">/</span>
<span class="token punctuation">[</span>root<span class="token annotation punctuation">@localhost</span> test<span class="token punctuation">]</span>## vim index<span class="token punctuation">.</span>html #在index<span class="token punctuation">.</span>html里面编写 <span class="token generics"><span class="token punctuation">&lt;</span>h1<span class="token punctuation">&gt;</span></span>hello tomcat<span class="token operator">&lt;</span><span class="token operator">/</span>h1<span class="token operator">&gt;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>浏览器测试访问：</p><p>http://192.168.128.130:8080/test/index.html</p><h3 id="_3-nginx-部署" tabindex="-1"><a class="header-anchor" href="#_3-nginx-部署" aria-hidden="true">#</a> 3.Nginx 部署</h3><p>1、搜索nginx镜像</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker search nginx</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>2、拉取nginx镜像</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker pull nginx</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>3、创建目录</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#mkdir nginx</span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#cd nginx</span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#mkdir conf</span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#cd conf</span>
<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#vim nginx.conf</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>4、编写nginx.conf配置文件</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>user  nginx<span class="token punctuation">;</span>
worker_processes  <span class="token number">1</span><span class="token punctuation">;</span>
error_log  /var/log/nginx/error.log warn<span class="token punctuation">;</span>
pid        /var/run/nginx.pid<span class="token punctuation">;</span>
events <span class="token punctuation">{</span>
    worker_connections  <span class="token number">1024</span><span class="token punctuation">;</span>
<span class="token punctuation">}</span>
http <span class="token punctuation">{</span>
    include       /etc/nginx/mime.types<span class="token punctuation">;</span>
    default_type  application/octet-stream<span class="token punctuation">;</span>

    log_format  main  <span class="token string">&#39;$remote_addr - $remote_user [$time_local] &quot;$request&quot; &#39;</span>
                      <span class="token string">&#39;$status $body_bytes_sent &quot;$http_referer&quot; &#39;</span>
                      <span class="token string">&#39;&quot;$http_user_agent&quot; &quot;$http_x_forwarded_for&quot;&#39;</span><span class="token punctuation">;</span>

    access_log  /var/log/nginx/access.log  main<span class="token punctuation">;</span>

    sendfile        on<span class="token punctuation">;</span> 
    keepalive_timeout  <span class="token number">65</span><span class="token punctuation">;</span>
    include /etc/nginx/conf.d/*.conf<span class="token punctuation">;</span>  
<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>说明：</p><p>第四步其实可以省略，默认创建一个nginx容器，会在/etc/nginx/目录下生成一个叫nginx.conf的配置文件，nginx容器启动会去加载该文件，该文件的内容和第四步配置文件的内容相同。这个文件的末尾有include /etc/nginx/conf.d/*.conf;这句话，也就说在conf.d目录下并且以conf结尾的文件都会被加载，而这个目录下只有一个配置文件就是default.conf，default.conf文件的内容配置了一个server节点，以及默认访问nginx的目录和首页（/html/index.html）</p></blockquote><p>5、创建nginx容器、端口映射、目录挂载</p><div class="language-powershell line-numbers-mode" data-ext="powershell"><pre class="language-powershell"><code><span class="token namespace">[root@localhost ~]</span><span class="token comment">#docker run -id --name=c_nginx \</span>
<span class="token operator">-</span>p 80:80 \
<span class="token operator">-</span>v <span class="token operator">/</span>root/nginx/conf/nginx<span class="token punctuation">.</span>conf:<span class="token operator">/</span>etc/nginx/nginx<span class="token punctuation">.</span>conf \  <span class="token comment">#不挂载这个配置文件也是可以的</span>
<span class="token operator">-</span>v <span class="token operator">/</span>root/nginx/logs:<span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>log/nginx \                    <span class="token comment">#nginx容器默认的日志文件保存到/var/log/nginx目录下</span>
<span class="token operator">-</span>v <span class="token operator">/</span>root/nginx/html:<span class="token operator">/</span>usr/share/nginx/html \             <span class="token comment">#nginx默认会去访问/usr/share/nginx/html下的index.html</span>
nginx

<span class="token operator">/</span><span class="token operator">/</span> nginx的配置文件也可以进行 挂载 否则使用vim在容器进行修改
<span class="token operator">-</span>v <span class="token operator">/</span>root/nginx/conf<span class="token punctuation">.</span>d:<span class="token operator">/</span>etc/nginx/conf<span class="token punctuation">.</span>d

docker run <span class="token operator">-</span>id <span class="token operator">--</span>name=c_nginx <span class="token operator">-</span>p 80:80 <span class="token operator">-</span>v <span class="token operator">/</span>root/nginx/conf/nginx<span class="token punctuation">.</span>conf:<span class="token operator">/</span>etc/nginx/nginx<span class="token punctuation">.</span>conf <span class="token operator">-</span>v <span class="token operator">/</span>root/nginx/logs:<span class="token operator">/</span><span class="token keyword">var</span><span class="token operator">/</span>log/nginx <span class="token operator">-</span>v <span class="token operator">/</span>root/nginx/html:<span class="token operator">/</span>usr/share/nginx/html nginx

docker run <span class="token operator">-</span>id <span class="token operator">--</span>name=c_nginx <span class="token operator">-</span>p 81:80 <span class="token operator">-</span>p 8004:8004 nginx
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>如果你不想挂载，所有的都可以不挂载，如果所有的都不挂载，默认情况，当创建nginx容器时，在/etc/nginx/目录下有nginx.conf这个文件，这个文件是nginx的配置文件，nginx容器启动的时候会去读这个配置文件</p></blockquote><p>6、在宿主机的/root/nginx/html目录下新建 index.html，让其同步到/usr/share/nginx/html目录下</p><p>测试访问：http://192.168.128.130/</p><h3 id="_4-redis-部署" tabindex="-1"><a class="header-anchor" href="#_4-redis-部署" aria-hidden="true">#</a> 4.Redis 部署</h3><p>1、搜索redis镜像</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker search redis</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>2、拉取redis镜像</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker pull redis:5.0</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>3、创建容器，设置端口映射</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker run -id --name=Apai_redis -p 6379:6379 --restart=always --restart=always redis:5.0</span>

<span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#docker run -id --name=c_redis2 -p 6380:6380 -v /root/redis/conf/redis.conf:/usr/local/bin/myredis.conf redis:5.0 /bin/bash -c &quot;redis-server /usr/local/bin/myredis.conf&quot;</span>
<span class="token comment">##把宿主机的redis.conf的port 改成port 6380</span>

<span class="token function">docker</span> run <span class="token parameter variable">-id</span> <span class="token parameter variable">--name</span><span class="token operator">=</span>Apai_redis <span class="token parameter variable">-p</span> <span class="token number">6379</span>:6379 <span class="token parameter variable">--restart</span><span class="token operator">=</span>always <span class="token parameter variable">-v</span> /Apai_File/redis/conf/redis.conf:/usr/local/bin/myredis.conf redis:5.0 /bin/bash <span class="token parameter variable">-c</span> <span class="token string">&quot;redis-server /usr/local/bin/myredis.conf&quot;</span>
<span class="token comment">##把宿主机的redis.conf的port 改成port 6380</span>
<span class="token function">docker</span> run <span class="token parameter variable">-id</span> <span class="token parameter variable">--name</span><span class="token operator">=</span>Apai_redis <span class="token parameter variable">-p</span> <span class="token number">6380</span>:6379 <span class="token parameter variable">--restart</span><span class="token operator">=</span>always redis:5.0 /bin/bash <span class="token parameter variable">-c</span> <span class="token string">&quot;redis-server /usr/local/bin/myredis.conf&quot;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>4、使用外部机器连接redis</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token punctuation">[</span>root@localhost ~<span class="token punctuation">]</span><span class="token comment">#./redis-cli.exe -h 192.168.149.135 -p 6379</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><h3 id="_5-rabbitmq-消息队列" tabindex="-1"><a class="header-anchor" href="#_5-rabbitmq-消息队列" aria-hidden="true">#</a> 5.RabbitMq 消息队列</h3><p><strong>注意:</strong></p><p>在java配置连接 消息队列 设置虚拟主机为:</p><p>1.拉去rabbitMq镜像</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token function">docker</span> pull rabbitmq:management
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>2.创建rabbitmq相关挂载目录</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token function">mkdir</span> <span class="token parameter variable">-p</span> /root/local/rabbitmq/<span class="token punctuation">{</span>data,conf,log<span class="token punctuation">}</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>3.创建完成之后要对所创建文件授权权限，都设置成777 否则在启动容器的时候容易失败</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token function">chmod</span> <span class="token parameter variable">-R</span> <span class="token number">777</span> /root/local/rabbitmq
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>4.镜像创建和启动容器</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token function">docker</span> run <span class="token parameter variable">--privileged</span><span class="token operator">=</span>true <span class="token parameter variable">-d</span> <span class="token parameter variable">-p</span> <span class="token number">5672</span>:5672 <span class="token parameter variable">-p</span> <span class="token number">15672</span>:15672 <span class="token parameter variable">--name</span> rabbitmq <span class="token parameter variable">-v</span> /root/local/rabbitmq/data:/var/lib/rabbitmq <span class="token parameter variable">-v</span> /root/local/rabbitmq/conf:/etc/rabbitmq <span class="token parameter variable">-v</span> /root/local/rabbitmq/log:/var/log/rabbitmq <span class="token parameter variable">--restart</span><span class="token operator">=</span>always <span class="token parameter variable">--hostname</span><span class="token operator">=</span>rabbitmqhost <span class="token parameter variable">-e</span> <span class="token assign-left variable">RABBITMQ_DEFAULT_VHOST</span><span class="token operator">=</span>my_vhost <span class="token parameter variable">-e</span> <span class="token assign-left variable">RABBITMQ_DEFAULT_USER</span><span class="token operator">=</span>admin <span class="token parameter variable">-e</span> <span class="token assign-left variable">RABBITMQ_DEFAULT_PASS</span><span class="token operator">=</span>admin rabbitmq
    
<span class="token comment">## 解析    </span>
端口映射 <span class="token parameter variable">-p</span> <span class="token number">5672</span>:5672 <span class="token parameter variable">-p</span> <span class="token number">15672</span>:15672
容器名称 <span class="token parameter variable">--name</span> rabbitmq 
设置用户密码及镜像名 <span class="token parameter variable">-e</span> <span class="token assign-left variable">RABBITMQ_DEFAULT_USER</span><span class="token operator">=</span>admin <span class="token parameter variable">-e</span> <span class="token assign-left variable">RABBITMQ_DEFAULT_PASS</span><span class="token operator">=</span>admin rabbitmq
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>5.进入容器</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token function">docker</span> <span class="token builtin class-name">exec</span> <span class="token parameter variable">-it</span> rabbitmq <span class="token function">bash</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>6.开启web管理端</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code>rabbitmq-plugins <span class="token builtin class-name">enable</span> rabbitmq_management
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div></div></div><p>附加:</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token number">1</span>.首先进入容器 <span class="token function">docker</span> <span class="token builtin class-name">exec</span> <span class="token parameter variable">-it</span> rabbitmq /bin/bash
<span class="token number">2</span>.创建用户 rabbitmqctl add_user admin1 admin1
<span class="token number">3</span>.给用户授权角色 rabbitmqctl set_user_tags admin1 administrator
<span class="token number">4</span>.给用户添加权限 rabbitmqctl set_permissions <span class="token parameter variable">-p</span> / admin1 <span class="token string">&quot;.*&quot;</span> <span class="token string">&quot;.*&quot;</span> <span class="token string">&quot;.*&quot;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>页面访问: http://192.168.174.133:15672</p><h3 id="_6-nacos-注册中心" tabindex="-1"><a class="header-anchor" href="#_6-nacos-注册中心" aria-hidden="true">#</a> 6.Nacos 注册中心</h3><p>https://blog.csdn.net/u013305864/article/details/125611099</p><p>编写docker-compose.yml文件 启动该文件 命令： docker-compose up</p><div class="language-yaml line-numbers-mode" data-ext="yml"><pre class="language-yaml"><code><span class="token key atrule">nacos</span><span class="token punctuation">:</span>
  <span class="token key atrule">image</span><span class="token punctuation">:</span> nacos/nacos<span class="token punctuation">-</span>server<span class="token punctuation">:</span>latest
  <span class="token key atrule">container_name</span><span class="token punctuation">:</span> nacos<span class="token punctuation">-</span><span class="token number">8848</span>
  <span class="token key atrule">environment</span><span class="token punctuation">:</span>
    <span class="token punctuation">-</span> PREFER_HOST_MODE=hostname
    <span class="token punctuation">-</span> MODE=standalone   <span class="token comment">#单机模式启动</span>
  <span class="token key atrule">volumes</span><span class="token punctuation">:</span>
    <span class="token punctuation">-</span> ./8848/logs/<span class="token punctuation">:</span>/home/nacos/logs   <span class="token comment">#前面是宿主机名  后面是容器目录名</span>
    <span class="token punctuation">-</span> ./8848/init.d/custom.properties<span class="token punctuation">:</span>/home/nacos/init.d/custom.properties
  <span class="token key atrule">ports</span><span class="token punctuation">:</span>
  <span class="token punctuation">-</span> <span class="token string">&quot;8848:8848&quot;</span>

</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>nacos 的默认服务端口是 <strong>8848</strong> ，启动完成之后通过浏览器访问 nacos：http://127.0.0.1:8848/nacos 。</p><p><strong>第一种</strong>（不推荐，因为不能连接数据库，进行持久化）</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token comment">#搜索可以使用的镜像</span>
<span class="token function">docker</span> search nacos
<span class="token comment">#拉取镜像</span>
<span class="token function">docker</span> pull nacos/nacos-server

<span class="token comment">## 运行nacos  挂载  --restart=always -&gt; 表示docker容器开机自启</span>
<span class="token function">docker</span>  run <span class="token parameter variable">--name</span> nacos <span class="token parameter variable">-d</span> <span class="token parameter variable">-p</span> <span class="token number">8848</span>:8848 <span class="token parameter variable">--privileged</span><span class="token operator">=</span>true <span class="token parameter variable">--restart</span><span class="token operator">=</span>always <span class="token parameter variable">-e</span> <span class="token assign-left variable">JVM_XMS</span><span class="token operator">=</span>256m <span class="token parameter variable">-e</span> <span class="token assign-left variable">JVM_XMX</span><span class="token operator">=</span>256m <span class="token parameter variable">-e</span> <span class="token assign-left variable">MODE</span><span class="token operator">=</span>standalone <span class="token parameter variable">-e</span> <span class="token assign-left variable">PREFER_HOST_MODE</span><span class="token operator">=</span>hostname <span class="token parameter variable">-v</span> /data/nacos/logs:/home/nacos/logs <span class="token parameter variable">-v</span> /data/nacos/conf:/home/nacos/conf nacos/nacos-server
<span class="token comment">## 不挂载 --restart=always -&gt; 表示docker容器开机自启</span>
<span class="token function">docker</span> run <span class="token parameter variable">--name</span> Apai_nacos <span class="token parameter variable">-d</span> <span class="token parameter variable">-p</span> <span class="token number">8848</span>:8848 <span class="token parameter variable">--privileged</span><span class="token operator">=</span>true <span class="token parameter variable">--restart</span><span class="token operator">=</span>always <span class="token parameter variable">-e</span> <span class="token assign-left variable">JVM_XMS</span><span class="token operator">=</span>256m <span class="token parameter variable">-e</span> <span class="token assign-left variable">JVM_XMX</span><span class="token operator">=</span>256m <span class="token parameter variable">-e</span> <span class="token assign-left variable">MODE</span><span class="token operator">=</span>standalone <span class="token parameter variable">-e</span> <span class="token assign-left variable">PREFER_HOST_MODE</span><span class="token operator">=</span>hostname nacos/nacos-server

<span class="token comment">#--restart=always 开机启动</span>

<span class="token comment">#检查是否启动</span>
<span class="token function">docker</span> <span class="token function">ps</span>
<span class="token comment">#访问地址 默认账号密码是nacos/nacos</span>
http://ip:8848/nacos
http://175.178.126.61:8848/nacos
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><p>第二种（强烈推荐用这种方式，因为可以持久化数据到数据库中，就算nacos容器出现了问题，数据也不受影响） 创建数据库脚本 https://github.com/alibaba/nacos/blob/master/config/src/main/resources/META-INF/nacos-db.sql</p><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token comment">#推荐使用这种方式，可以连接自己的数据库</span>
<span class="token function">docker</span> run <span class="token parameter variable">-d</span> <span class="token parameter variable">-p</span> <span class="token number">8848</span>:8848 <span class="token parameter variable">-p</span> <span class="token number">9848</span>:9848 <span class="token punctuation">\</span>
<span class="token parameter variable">--name</span> nacos <span class="token punctuation">\</span>
<span class="token parameter variable">--env</span> <span class="token assign-left variable">MODE</span><span class="token operator">=</span>standalone <span class="token punctuation">\</span>
<span class="token parameter variable">--env</span> <span class="token assign-left variable">SPRING_DATASOURCE_PLATFORM</span><span class="token operator">=</span>mysql <span class="token punctuation">\</span>
<span class="token parameter variable">--env</span> <span class="token assign-left variable">MYSQL_SERVICE_HOST</span><span class="token operator">=</span><span class="token number">192.168</span>.0.12 <span class="token punctuation">\</span>
<span class="token parameter variable">--env</span> <span class="token assign-left variable">MYSQL_SERVICE_PORT</span><span class="token operator">=</span><span class="token number">3306</span> <span class="token punctuation">\</span>
<span class="token parameter variable">--env</span> <span class="token assign-left variable">MYSQL_SERVICE_DB_NAME</span><span class="token operator">=</span>nacos <span class="token punctuation">\</span>
<span class="token parameter variable">--env</span> <span class="token assign-left variable">MYSQL_SERVICE_USER</span><span class="token operator">=</span>root <span class="token punctuation">\</span>
<span class="token parameter variable">--env</span> <span class="token assign-left variable">MYSQL_SERVICE_PASSWORD</span><span class="token operator">=</span>wisesoft <span class="token punctuation">\</span>
nacos/nacos-server:latest

<span class="token comment">#访问地址 默认账号密码是nacos/nacos</span>
http://ip:8848/nacos
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// -------- 补充 -----------</span>
<span class="token comment">// 拉取指定版本的nacos https://blog.csdn.net/weixin_41798072/article/details/125945878</span>
docker pull nacos<span class="token operator">/</span>nacos<span class="token operator">-</span>server<span class="token operator">:</span><span class="token number">1.4</span><span class="token number">.1</span>
<span class="token comment">// 不挂载 --restart=always -&gt; 表示docker容器开机自启</span>
docker run <span class="token operator">--</span>name <span class="token class-name">Apai_nacos</span> <span class="token operator">-</span>d <span class="token operator">-</span>p <span class="token number">8848</span><span class="token operator">:</span><span class="token number">8848</span> <span class="token operator">--</span>privileged<span class="token operator">=</span><span class="token boolean">true</span> <span class="token operator">--</span>restart<span class="token operator">=</span>always <span class="token operator">-</span>e <span class="token constant">JVM_XMS</span><span class="token operator">=</span><span class="token number">256</span>m <span class="token operator">-</span>e <span class="token constant">JVM_XMX</span><span class="token operator">=</span><span class="token number">256</span>m <span class="token operator">-</span>e <span class="token constant">MODE</span><span class="token operator">=</span>standalone <span class="token operator">-</span>e <span class="token constant">PREFER_HOST_MODE</span><span class="token operator">=</span>hostname nacos<span class="token operator">/</span>nacos<span class="token operator">-</span>server<span class="token operator">:</span><span class="token number">1.4</span><span class="token number">.1</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><h3 id="_7-minio-对象存储" tabindex="-1"><a class="header-anchor" href="#_7-minio-对象存储" aria-hidden="true">#</a> 7.Minio 对象存储</h3><p><strong>拉取 minio 镜像</strong></p><div class="language-java line-numbers-mode" data-ext="java"><pre class="language-java"><code><span class="token comment">// minio 文件对象存储 类似阿里云oss</span>
docker pull minio<span class="token operator">/</span>minio 
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div></div></div><p><strong>创建 minio 容器</strong></p><ul><li>--console-address &quot;:9000&quot; 表示minio的 前端页面的端口</li><li>--address &quot;:9090&quot; 表示minio的文件上传API 的端口 | 在yml 需配置 9090</li></ul><div class="language-bash line-numbers-mode" data-ext="sh"><pre class="language-bash"><code><span class="token function">docker</span> run <span class="token parameter variable">-id</span> <span class="token parameter variable">--name</span><span class="token operator">=</span>minio <span class="token parameter variable">-p</span> <span class="token number">9000</span>:9000 <span class="token parameter variable">-p</span> <span class="token number">9090</span>:9090 <span class="token parameter variable">-e</span> <span class="token string">&quot;MINIO_PROMETHEUS_AUTH_TYPE=public&quot;</span> <span class="token punctuation">\</span>
<span class="token parameter variable">-e</span> <span class="token string">&quot;MINIO_ROOT_USER=minioadmin&quot;</span> <span class="token parameter variable">-e</span> <span class="token string">&quot;MINIO_ROOT_PASSWORD=minioadmin&quot;</span> <span class="token punctuation">\</span>
<span class="token parameter variable">-v</span> /mnt/minio/data:/data <span class="token parameter variable">-v</span> /mnt/minio/config:/root/.minio minio/minio server /data <span class="token punctuation">\</span>
--console-address <span class="token string">&quot;:9000&quot;</span> <span class="token parameter variable">--address</span> <span class="token string">&quot;:9090&quot;</span>
</code></pre><div class="line-numbers" aria-hidden="true"><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div><div class="line-number"></div></div></div><blockquote><p>--console-address &quot;:9000&quot; --address &quot;:9090&quot; docker使用静态的固定端口，以避免启动时使用随机端口</p></blockquote><p>浏览器访问：192.168.128.128:9000</p><p>java上传: 9090</p></div></div><footer class="page-meta"><!----><div class="meta-item last-updated"><span class="xicon-container left meta-item-label"><!--[--><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 32 32" class="xicon-icon" style="width:20px;height:20px;font-size:20px;color:inherit;"><path d="M26 4h-4V2h-2v2h-8V2h-2v2H6c-1.1 0-2 .9-2 2v20c0 1.1.9 2 2 2h20c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 22H6V12h20v14zm0-16H6V6h4v2h2V6h8v2h2V6h4v4z" fill="currentColor"></path></svg><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Last Updated 2023-07-19 09:58:39<!--]--></span></span></div></footer><!----><!----></main><!--]--><div class="page-catalog-container"><h5 class="tip">文章层级目录</h5><ul><!--[--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#linux" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Linux"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#文件管理" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="文件管理"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文件管理<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#配置全路径名" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="配置全路径名"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->配置全路径名<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#linux-系统-固定-ip" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Linux 系统 固定 - IP"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux 系统 固定 - IP<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#linux-文件与目录管理" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Linux 文件与目录管理"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux 文件与目录管理<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#处理目录的常用命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="处理目录的常用命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->处理目录的常用命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#linux-文件内容查看" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Linux 文件内容查看"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux 文件内容查看<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#linux-功能类命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Linux 功能类命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux 功能类命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#tar-压缩解压命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="tar 压缩解压命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->tar 压缩解压命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#网络命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="网络命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->网络命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#用户管理命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="用户管理命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->用户管理命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#挂载命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="挂载命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->挂载命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#关机重启命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="关机重启命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->关机重启命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#dos文本和unix格式转换" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="dos文本和unix格式转换"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->dos文本和unix格式转换<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#系统类命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="系统类命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->系统类命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#wget-命令下载" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="wget 命令下载"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->wget 命令下载<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#后台运行jar包" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="后台运行jar包"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->后台运行jar包<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#防火墙-端口" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="防火墙 端口"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->防火墙 端口<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#查看linux运行的进程" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="查看linux运行的进程"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->查看linux运行的进程<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#管道符" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="管道符  |"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->管道符  |<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#vim-文本编辑器" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="vim -- 文本编辑器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->vim -- 文本编辑器<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#vi-vim-的使用" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="vi/vim 的使用"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->vi/vim 的使用<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#文件编辑命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="文件编辑命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文件编辑命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#vim使用技巧" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Vim使用技巧"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Vim使用技巧<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#linux-yum-命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Linux yum 命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux yum 命令<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#yum-语法" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="yum 语法"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->yum 语法<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#yum常用命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="yum常用命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->yum常用命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#nginx-分隔" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="------------   nginx 分隔    -----------"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->------------   nginx 分隔    -----------<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#nginx-反向代理-服务器" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="nginx 反向代理 服务器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->nginx 反向代理 服务器<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#版本和安装" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="版本和安装"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->版本和安装<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#nginx配置文件" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="nginx配置文件"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->nginx配置文件<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#配置虚拟主机" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="配置虚拟主机"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->配置虚拟主机<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#反向代理" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="反向代理"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->反向代理<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#案例" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="案例"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->案例<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#负载均衡" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="负载均衡"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->负载均衡<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#负载均衡的配置" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="负载均衡的配置"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->负载均衡的配置<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#负载方式" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="负载方式"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->负载方式<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#将客户端浏览器的-ip-传递到后台" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="将客户端浏览器的 IP 传递到后台"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->将客户端浏览器的 IP 传递到后台<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#nginx解决前后端跨域-了解" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="nginx解决前后端跨域(了解)"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->nginx解决前后端跨域(了解)<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#nginx搭建文件服务器" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="nginx搭建文件服务器"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->nginx搭建文件服务器<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#docker-分隔" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="-----------  Docker 分隔   -----------"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->-----------  Docker 分隔   -----------<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#docker-容器引擎" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Docker 容器引擎"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Docker 容器引擎<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#nacos-的下载和安装" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Nacos 的下载和安装"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Nacos 的下载和安装<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#docker-概念" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="docker 概念"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->docker 概念<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#docker-网络模式" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Docker 网络模式"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Docker 网络模式<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#bridge-模式-桥接" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="bridge 模式 - 桥接"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->bridge 模式 - 桥接<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#host-模式-仅主机模式" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="host 模式 - 仅主机模式"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->host 模式 - 仅主机模式<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#container-模式" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="container 模式"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->container 模式<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#docker-命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Docker 命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Docker 命令<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#进程相关命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="进程相关命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->进程相关命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#镜像相关命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="镜像相关命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->镜像相关命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#容器相关命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="容器相关命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->容器相关命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#docker-镜像制作" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Docker 镜像制作"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Docker 镜像制作<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#docker-镜像原理" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Docker 镜像原理"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Docker 镜像原理<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#普通方式" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="普通方式"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->普通方式<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#dockerfile方式" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="dockerfile方式"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->dockerfile方式<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#compose-服务编排" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Compose 服务编排"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Compose 服务编排<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#安装-compose" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="安装 Compose"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->安装 Compose<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#卸载-compose" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="卸载 Compose"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->卸载 Compose<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#comnpose的使用步骤" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Comnpose的使用步骤"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Comnpose的使用步骤<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#分隔" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="------------   分隔    ------------"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->------------   分隔    ------------<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#linux-常用命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Linux 常用命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux 常用命令<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#文件类-功能类-命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="文件类 功能类 命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->文件类 功能类 命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#redis-命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="redis  命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->redis  命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#nginx-命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="nginx  命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->nginx  命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#运行jar包-命令" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="运行jar包 命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->运行jar包 命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#docker-命令-1" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Docker 命令"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Docker 命令<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#项目-部署" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="项目 部署"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->项目 部署<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#war包部署" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="war包部署"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->war包部署<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#jar包部署" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="jar包部署"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->jar包部署<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#ngins-进行-项目部署" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="ngins 进行 项目部署"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->ngins 进行 项目部署<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#linux-安装" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Linux 安装"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Linux 安装<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#nginx-安装" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="nginx 安装"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->nginx 安装<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#源码包" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="源码包"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->源码包<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#脚本包" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="脚本包"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->脚本包<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#rpm包-二进制包" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="rpm包（二进制包)"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->rpm包（二进制包)<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#yum安装" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="yum安装"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->yum安装<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#工具-安装" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="工具 安装"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->工具 安装<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--[--><li class="page-catalog-menu-depth_2"><a aria-current="page" href="/docs/Linux-develop/Linux.html#docker-应用部署" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="Docker 应用部署"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->Docker 应用部署<!--]--></span></span><!--[--><!--]--></a></li><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#_1-mysql-部署" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="1.mysql  部署"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->1.mysql  部署<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#_2-tomcat-部署" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="2.Tomcat  部署"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->2.Tomcat  部署<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#_3-nginx-部署" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="3.Nginx  部署"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->3.Nginx  部署<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#_4-redis-部署" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="4.Redis  部署"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->4.Redis  部署<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#_5-rabbitmq-消息队列" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="5.RabbitMq 消息队列"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->5.RabbitMq 消息队列<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#_6-nacos-注册中心" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="6.Nacos 注册中心"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->6.Nacos 注册中心<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--[--><li class="page-catalog-menu-depth_3"><a aria-current="page" href="/docs/Linux-develop/Linux.html#_7-minio-对象存储" class="router-link-active router-link-exact-active link page-catalog-item" aria-label="7.Minio 对象存储"><!--[--><!--]--><span class="xicon-container left"><!--[--><!----><!--]--><span class="xicon-content" style="color:inherit;font-size:14px;"><!--[-->7.Minio 对象存储<!--]--></span></span><!--[--><!--]--></a></li><!--]--><!--]--><!--]--></ul></div></div></div></div><!----><!----><!--]--></div>
    <script type="module" src="/assets/app-8a43a0f0.js" defer></script>
  </body>
</html>
